Skip to content

Commit 47109df

Browse files
committed
Check for touch event on canvas objects before invoking plane events.
1 parent 8f4d28a commit 47109df

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

Scripts/ARPlaneEvents.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using UnityEngine;
22
using UnityEngine.Events;
3+
using UnityEngine.EventSystems;
34
using UnityEngine.XR.ARFoundation;
45

56
namespace CandyCoded.ARFoundationComponents
@@ -58,10 +59,16 @@ private void Update()
5859

5960
PlaneUpdated?.Invoke(planeVisible, lookingAtPose, lookingAtPlane);
6061

61-
if (ARFoundationExtensions.HasTouchedPlane(sessionOrigin, planeManager, out Pose touchPose, out ARPlane touchPlane))
62+
if (InputManager.GetInputDown(out int currentFingerId) && !EventSystem.current.IsPointerOverGameObject(currentFingerId))
6263
{
6364

64-
PlaneTouchedWithTouchPosition?.Invoke(touchPose, touchPlane);
65+
if (ARFoundationExtensions.HasTouchedPlane(sessionOrigin, planeManager, out Pose touchPose, out ARPlane touchPlane))
66+
{
67+
68+
PlaneTouchedWithTouchPosition?.Invoke(touchPose, touchPlane);
69+
70+
}
71+
6572
PlaneTouchedWithLookingAtPosition?.Invoke(lookingAtPose, lookingAtPlane);
6673

6774
}

0 commit comments

Comments
 (0)