判断手指是否点击到指定UI
作者:
道阻且长_行则将至 | 来源:发表于
2017-10-22 00:27 被阅读20次public class TestTouch : MonoBehaviour {
public Text text;
void Update()
{
if (Input.GetMouseButtonDown(0) || (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Began))
{
#if UNITY_ANDROID || UNITY_IPHONE
if (EventSystem.current.IsPointerOverGameObject(Input.GetTouch(0).fingerId))
#else
if (EventSystem.current.IsPointerOverGameObject())
#endif
text.text = "当前触摸在UI上";
else
text.text = "当前没有触摸在UI上";
}
}
}
本文标题:判断手指是否点击到指定UI
本文链接:https://www.haomeiwen.com/subject/ckawuxtx.html
网友评论