#if IPHONE || ANDROID if (EventSystem.current.IsPointerOverGameObject(Input.GetTouch(0).fingerId)) #else if (EventSystem.current.IsPointerOverGameObject()) #endif Debug.Log("当前触摸在UI上"); else Debug.Log("当前没有触摸在UI上");
注意EventSystem.current.IsPointerOverGameObject是指点击的物体是否是一个能响应EventSystem的物体(也就是UGUI控件)