【发布时间】:2023-03-28 08:28:01
【问题描述】:
我在统一 2d 中创建了一个 UI 按钮,它工作正常。但我认为事件触发组件不起作用。当光标在按钮上时,我想使按钮变大,并在光标退出时恢复正常大小。这是我的脚本...
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayAgainButton : MonoBehaviour
{
public void PointerEnter()
{
Debug.Log("Enter");
transform.localScale = new Vector2(1.2f, 1.2f);
}
public void PointerExit()
{
Debug.Log("Exit");
transform.localScale = new Vector2(1f, 1f);
}
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
}
玩游戏时控制台提示光标进出
但按钮的比例永远不会改变。
这里有什么问题?
【问题讨论】:
-
其他东西似乎会覆盖比例,例如像
HorizontalLayoutGroup这样的任何东西都启用了控制子规模
标签: c# unity3d user-interface eventtrigger