Skip to content

Commit 2df0a7b

Browse files
committed
fix(Util): Over GUI on mobile
1 parent 595a756 commit 2df0a7b

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

Assets/JCSUnity/Scripts/Util/JCS_UIUtil.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -888,7 +888,19 @@ public static bool MouseOverGUI(RectTransform imageRect, RectTransform rootPanel
888888
/// </returns>
889889
public static bool IsOverGUI()
890890
{
891+
#if (UNITY_EDITOR || UNITY_STANDALONE || UNITY_WEBGL)
891892
return EventSystem.current.IsPointerOverGameObject();
893+
#elif (UNITY_ANDROID || UNITY_IPHIONE || UNITY_IOS)
894+
if (Input.touchCount <= 0)
895+
return false;
896+
897+
Touch touch = Input.GetTouch(0);
898+
899+
return EventSystem.current.IsPointerOverGameObject(touch.fingerId);
900+
#else
901+
// Fallback return.
902+
return EventSystem.current.IsPointerOverGameObject();
903+
#endif
892904
}
893905
}
894906
}

0 commit comments

Comments
 (0)