C# 如何检测屏幕单元2D左下20%的触摸?
我试图找出如何只在屏幕的特定区域检测触摸。当我有条件的时候C# 如何检测屏幕单元2D左下20%的触摸?,c#,unity3d,C#,Unity3d,我试图找出如何只在屏幕的特定区域检测触摸。当我有条件的时候 "touch.position.x < Screen.width / 2" 然后我得到它在x轴上对屏幕的一半起作用,但当我尝试添加高度条件时,它不起作用 foreach (Touch touch in Input.touches) { if (touch.position.x < Screen.width / 2 && touch.position.y / 2 < Screen
"touch.position.x < Screen.width / 2"
然后我得到它在x轴上对屏幕的一半起作用,但当我尝试添加高度条件时,它不起作用
foreach (Touch touch in Input.touches)
{
if (touch.position.x < Screen.width / 2 && touch.position.y / 2 < Screen.height)
{
Debug.Log("Touch");
}
}
仅供参考:
touch.position.y / 2 < Screen.height;
已经是真的了…所以我想你应该写这行:
touch.position.y < Screen.height / 2;
在这种情况下,只有屏幕的左上部分是可触摸的可能是打字错误吗?touch.position.y/2