码迷,mamicode.com
首页 > 其他好文 > 详细

U3D 精灵的点击监听

时间:2015-12-27 19:11:17      阅读:142      评论:0      收藏:0      [点我收藏+]

标签:

U3D游戏中,可能会用到点击对象,完成某项操作,

方法一:可以通过接收Input对象的输入,进行利用

方法二:给对象绑定一个collier 组件,然后就能后使用内置方法

    void OnMouseDown() {
        print("鼠标按下了");
    }

只要给精灵绑定这个组件,那么鼠标的一系列的操作就都可以完成

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

 

U3D 精灵的点击监听

标签:

原文地址:http://www.cnblogs.com/sunxun/p/5080498.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!