单击我制作的UI图像时,'void OnMouseDown()'函数不起作用! 我尝试过的事情:
我的剧本:
public class btnPlay : MonoBehaviour, IPointerDownHandler {
Vector3 pos;
// Update is called once per frame
void Update () {
pos = new Vector3 (Screen.width / 4.6f, Screen.height / 1.58f, -1f);
transform.position = pos;
}
void OnPointerDown(PointerEventData p) {
Debug.Log ("X");
SceneManager.LoadScene ("Level");
}
}
答案 0 :(得分:0)
刚刚添加了界面IPointerDownHandler
和using UnityEngine.EventSystems
比,我把方法改为public
。
感谢@yes提供答案