Unity3d:如何检测区域内的点击

www*_*com 2 unity-game-engine

在Unity3d应用程序中,我试图检测当前相机的某个平方区域中的点击.有没有办法做到这一点?

谢谢

Lan*_*nce 6

这不是你想要的吗?

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!");            
        }
    }
}
Run Code Online (Sandbox Code Playgroud)