Skip to content

Commit d446dc5

Browse files
Add Scene 14 and corresponding test for object detection (#1865)
1 parent 637932c commit d446dc5

File tree

5 files changed

+721
-12
lines changed

5 files changed

+721
-12
lines changed

Assets/AltTester/Runtime/Input/FindObjectViaRayCast.cs

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,13 @@ private static GameObject findEventSystemObject(PointerEventData pointerEventDat
3333
{
3434
List<RaycastResult> firstRaycastResult;
3535
GetAllRaycastResults(pointerEventData, out firstRaycastResult);
36-
foreach (var result in firstRaycastResult)
37-
{
38-
if (ExecuteEvents.CanHandleEvent<IPointerClickHandler>(result.gameObject))
39-
{
40-
return result.gameObject;
41-
}
42-
}
43-
foreach (var result in firstRaycastResult)//if nothing has click handler then return the first UI element encountered
44-
{
45-
return result.gameObject;
46-
}
47-
return null;
36+
if (firstRaycastResult.Count == 0)
37+
return null;
38+
GameObject topMostObject = firstRaycastResult[0].gameObject;
39+
GameObject clickHandler = ExecuteEvents.GetEventHandler<IPointerClickHandler>(topMostObject);
40+
41+
return clickHandler != null ? clickHandler : topMostObject;
42+
4843
}
4944
public static GameObject FindObjectAtCoordinates(Vector2 screenPosition)
5045
{

0 commit comments

Comments
 (0)