EventSystem使用

1、对于UI组件,新建一个sprite,被sprite绑定一下脚本

public class testt : MonoBehaviour, IPointerDownHandler{

public void OnPointerDown(PointerEventData eventData)
{
Debug.Log("点击");
}

// Use this for initialization
void Start () {

}

// Update is called once per frame
void Update () {

}
}

实现了IPointerDownHandler,OnPointerDown响应按下动作,还有两个类似接口如下

IPointerUpHandler接口,实现接口响应按钮抬起动作,

IPointerExitHandler接口,不用按下,鼠标位置离开对象自动调用;

 

2、对于非UI对象

在摄像机添加Physics Raycaster

其余跟上面一样

posted on 2017-03-04 16:50  wzhhh  阅读(136)  评论(0)    收藏  举报

导航