Skip to content

Instantly share code, notes, and snippets.

@glebov21
Created February 21, 2018 15:53
Show Gist options
  • Save glebov21/04c7b7944ae9af69f01f4a9330abec15 to your computer and use it in GitHub Desktop.
Save glebov21/04c7b7944ae9af69f01f4a9330abec15 to your computer and use it in GitHub Desktop.
Is cursor or touch under ui (unity3d)
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