鼠标的监听一共有以下这几种方法
OnMouseDown | OnMouseDown is called when the user has pressed the mouse button while over the GUIElement or Collider. |
OnMouseDrag | OnMouseDrag is called when the user has clicked on a GUIElement or Collider and is still holding down the mouse. |
OnMouseEnter | Called when the mouse enters the GUIElement or Collider. |
OnMouseExit | Called when the mouse is not any longer over the GUIElement or Collider. |
OnMouseOver | Called every frame while the mouse is over the GUIElement or Collider. |
OnMouseUp | OnMouseUp is called when the user has released the mouse button. |
OnMouseUpAsButton | OnMouseUpAsButton is only called when the mouse is released over the same GUIElement or Collider as it was pressed. |
在控制GameObject的脚本中添加以下代码就可以监听鼠标的点击事件
在MonoBehaviour类中,添加OnMouseUpAsButton()这个方法,比较像Button的OnClick
void OnMouseUpAsButton(){ Debug.Log ("OnClick"); }
暂无关于此日志的评论。