您的位置:首页 > 移动开发 > Unity3D

unity检测鼠标是点击在UI上还是物体上

2017-02-27 21:55 453 查看
void Update()
{
if (Input.GetMouseButtonDown(0)||(Input.touchCount >0 && Input.GetTouch(0).phase == TouchPhase.Began))
{
#if IPHONE || ANDROID
if (EventSystem.current.IsPointerOverGameObject(Input.GetTouch(0).fingerId))
#else
if (EventSystem.current.IsPointerOverGameObject())
#endif
Debug.Log("当前触摸在UI上");

else
Debug.Log("当前没有触摸在UI上");
}
}


  
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: