Skip to content

Commit 560cce4

Browse files
committed
Make sure we properly fall back to other input subsystems
1 parent 0e833a7 commit 560cce4

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

Assets/MRTK/Providers/XRSDK/XRSDKBoundarySystem.cs

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,19 @@ protected override List<Vector3> GetBoundaryGeometry()
4343
// Get the boundary geometry.
4444
var boundaryGeometry = new List<Vector3>(0);
4545

46-
if (!XRSubsystemHelpers.InputSubsystem.TryGetBoundaryPoints(boundaryGeometry) || boundaryGeometry.Count == 0)
46+
if (XRSubsystemHelpers.InputSubsystem?.GetTrackingOriginMode() != TrackingOriginModeFlags.Floor
47+
|| !XRSubsystemHelpers.InputSubsystem.TryGetBoundaryPoints(boundaryGeometry)
48+
|| boundaryGeometry.Count == 0)
4749
{
4850
#if UNITY_2019_3_OR_NEWER
4951
// If the "main" input subsystem doesn't have an available boundary, check the rest of them
5052
SubsystemManager.GetInstances(XRInputSubsystems);
5153
foreach (XRInputSubsystem xrInputSubsystem in XRInputSubsystems)
5254
{
53-
if (xrInputSubsystem.running &&
54-
xrInputSubsystem.TryGetBoundaryPoints(boundaryGeometry) &&
55-
boundaryGeometry.Count > 0)
55+
if (xrInputSubsystem.running
56+
&& xrInputSubsystem.GetTrackingOriginMode() == TrackingOriginModeFlags.Floor
57+
&& xrInputSubsystem.TryGetBoundaryPoints(boundaryGeometry)
58+
&& boundaryGeometry.Count > 0)
5659
{
5760
break;
5861
}
@@ -91,8 +94,19 @@ protected override void SetTrackingSpace()
9194
break;
9295
}
9396

94-
if (XRSubsystemHelpers.InputSubsystem != null && !XRSubsystemHelpers.InputSubsystem.TrySetTrackingOriginMode(trackingOriginMode))
97+
if (XRSubsystemHelpers.InputSubsystem == null || !XRSubsystemHelpers.InputSubsystem.TrySetTrackingOriginMode(trackingOriginMode))
9598
{
99+
#if UNITY_2019_3_OR_NEWER
100+
// If the "main" input subsystem can't set the origin mode, check the rest of them
101+
SubsystemManager.GetInstances(XRInputSubsystems);
102+
foreach (XRInputSubsystem xrInputSubsystem in XRInputSubsystems)
103+
{
104+
if (xrInputSubsystem.running && xrInputSubsystem.TrySetTrackingOriginMode(trackingOriginMode))
105+
{
106+
return;
107+
}
108+
}
109+
#endif // UNITY_2019_3_OR_NEWER
96110
Debug.LogWarning("Tracking origin unable to be set.");
97111
}
98112
}

0 commit comments

Comments
 (0)