unity中的MonoBehaviour.OnMouseDown()

来源:互联网 发布:气质美女知乎 编辑:程序博客网 时间:2024/04/25 10:25

在官网的api文档中仅说明了

Description

OnMouseDown is called when the user has pressed the mouse button while over theGUIElement orCollider.

This event is sent to all scripts of the Collider or GUIElement.


首先OnMouseDown()对2d和3d的物体都有效。

经过我的试验,B是A子物体,如果A和B都有collider,点击谁就执行谁脚本的OnMouseDown()。

而且只能点到最外的物体,比如A和B是两个独立的物体,A把B遮到了,就只能点到A。B是不会执行的。

(说个话外题:禁用脚本只是禁用了awake(),start(),update(),fixedupdate(),ongui()五个函数,其他的还是有效的)。


0 0
原创粉丝点击