在 Unity3d 应用程序中,我尝试检测当前相机的某个方形区域中的单击。有什么办法可以做到这一点吗?
谢谢
这不是您要找的吗?
http://unity3d.com/support/documentation/ScriptReference/Input-mousePosition.html http://unity3d.com/support/documentation/ScriptReference/Input-mousePosition.html
** 编辑 **
using UnityEngine;
public class example : MonoBehaviour
{
void Update()
{
// Left-half of the screen.
Rect bounds = new Rect(0, 0, Screen.width/2, Screen.height);
if (Input.GetMouseButtonDown(0) && bounds.Contains(Input.mousePosition))
{
Debug.Log("Left!");
}
}
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)