Skip to content

Instantly share code, notes, and snippets.

@StewMcc
Created April 25, 2018 17:16
Show Gist options
  • Save StewMcc/4c45a11eecf0f5aefae29444d1ba5fbe to your computer and use it in GitHub Desktop.
Save StewMcc/4c45a11eecf0f5aefae29444d1ba5fbe to your computer and use it in GitHub Desktop.
public class UnityUiExtensions {
/// <summary>
/// Check if the mouse or first finger is over Unity UI element.
/// </summary>
/// <returns></returns>
private bool IsOverUi() {
#if (UNITY_ANDROID || UNITY_IOS) && !UNITY_EDITOR
return EventSystem.current.IsPointerOverGameObject(Input.GetTouch(0).fingerId);
#else
return EventSystem.current.IsPointerOverGameObject();
#endif
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment