Created
February 21, 2018 15:53
-
-
Save glebov21/04c7b7944ae9af69f01f4a9330abec15 to your computer and use it in GitHub Desktop.
Is cursor or touch under ui (unity3d)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static bool IsCursorOrTouchUnderUI() | |
{ | |
if (EventSystem.current == null) | |
return true; | |
if (EventSystem.current.enabled == false) | |
return true; | |
if (EventSystem.current.currentSelectedGameObject != null) | |
return true; | |
if (EventSystem.current.IsPointerOverGameObject()) //лишняя и грузит? Если проблем нет, то удалить | |
return true; | |
if (Input.touchCount > 0 && EventSystem.current.IsPointerOverGameObject(Input.GetTouch(0).fingerId)) | |
return true; | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment