Skip to content

Commit e52a113

Browse files
committed
Also gate on this base observer being the only active observer
1 parent 284754f commit e52a113

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

Assets/MRTK/Providers/XRSDK/GenericXRSDKSpatialMeshObserver.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,24 @@ protected virtual bool? IsActiveLoader
5252
&& XRGeneralSettings.Instance.Manager != null
5353
&& XRGeneralSettings.Instance.Manager.activeLoader != null)
5454
{
55+
if ((observersCache == null || observersCache.Count == 0)
56+
&& Service is IMixedRealityDataProviderAccess spatialAwarenessDataProviderAccess
57+
&& Service is IMixedRealityServiceState spatialAwarenessState
58+
&& spatialAwarenessState.IsInitialized)
59+
{
60+
observersCache = spatialAwarenessDataProviderAccess.GetDataProviders<GenericXRSDKSpatialMeshObserver>();
61+
}
62+
63+
// Don't report ourselves as active if another observer is handling this platform
64+
for (int i = 0; i < observersCache?.Count; i++)
65+
{
66+
GenericXRSDKSpatialMeshObserver observer = observersCache[i];
67+
if (observer != this && (observer.IsActiveLoader ?? false))
68+
{
69+
return false;
70+
}
71+
}
72+
5573
return true;
5674
}
5775

0 commit comments

Comments
 (0)