14
14
using System . Threading ;
15
15
using System . Threading . Tasks ;
16
16
using Microsoft . MixedReality . SceneUnderstanding ;
17
- #if WINDOWS_UWP
18
- using Windows . Perception . Spatial ;
19
- using Windows . Perception . Spatial . Preview ;
20
17
#if MSFT_OPENXR
21
18
using Microsoft . MixedReality . OpenXR ;
19
+ using Microsoft . MixedReality . OpenXR . Remoting ;
22
20
using Microsoft . MixedReality . Toolkit . XRSDK ;
23
21
using UnityEngine . XR . OpenXR ;
24
22
#endif // MSFT_OPENXR
23
+ #if WINDOWS_UWP
24
+ using Windows . Perception . Spatial ;
25
+ using Windows . Perception . Spatial . Preview ;
25
26
#endif // WINDOWS_UWP
26
27
using UnityEngine . Assertions ;
27
28
using UnityEngine . EventSystems ;
@@ -129,13 +130,12 @@ public override void Initialize()
129
130
}
130
131
#else
131
132
base . Initialize ( ) ;
132
- #if WINDOWS_UWP
133
133
#if MSFT_OPENXR
134
134
isOpenXRLoaderActive = LoaderHelpers . IsLoaderActive < OpenXRLoaderBase > ( ) ?? false ;
135
- #else
135
+ isOpenXRRemotingConnected = AppRemoting . TryGetConnectionState ( out ConnectionState state , out _ ) && state == ConnectionState . Connected ;
136
+ #elif WINDOWS_UWP
136
137
isOpenXRLoaderActive = false ;
137
138
#endif // MSFT_OPENXR
138
- #endif // WINDOWS_UWP
139
139
sceneEventData = new MixedRealitySpatialAwarenessEventData < SpatialAwarenessSceneObject > ( EventSystem . current ) ;
140
140
CreateQuadFromExtents ( normalizedQuadMesh , 1 , 1 ) ;
141
141
@@ -419,9 +419,12 @@ private enum ObserverState
419
419
private System . Numerics . Matrix4x4 sceneToWorldTransformMatrix ;
420
420
private List < SceneObject > filteredSelectedSurfaceTypesResult = new List < SceneObject > ( 128 ) ;
421
421
private Texture defaultTexture ;
422
- #if WINDOWS_UWP
422
+ #if WINDOWS_UWP || MSFT_OPENXR
423
423
private bool isOpenXRLoaderActive ;
424
- #endif // WINDOWS_UWP
424
+ #endif // WINDOWS_UWP || MSFT_OPENXR
425
+ #if MSFT_OPENXR
426
+ private bool isOpenXRRemotingConnected ;
427
+ #endif // MSFT_OPENXR
425
428
426
429
#endregion Private Fields
427
430
@@ -794,8 +797,13 @@ private async Task RunObserverAsync(CancellationToken cancellationToken)
794
797
private System . Numerics . Matrix4x4 ? GetSceneToWorldTransform ( )
795
798
{
796
799
var result = System . Numerics . Matrix4x4 . Identity ;
797
- #if WINDOWS_UWP
800
+ #if WINDOWS_UWP // On HoloLens 2 device
798
801
if ( isOpenXRLoaderActive )
802
+ #elif MSFT_OPENXR // In editor and using OpenXR
803
+ if ( isOpenXRLoaderActive && isOpenXRRemotingConnected && ! ShouldLoadFromFile )
804
+ #else // All other cases
805
+ if ( false )
806
+ #endif // WINDOWS_UWP
799
807
{
800
808
#if MSFT_OPENXR
801
809
SpatialGraphNode node = SpatialGraphNode . FromStaticNodeId ( sceneOriginId ) ;
@@ -811,6 +819,7 @@ private async Task RunObserverAsync(CancellationToken cancellationToken)
811
819
}
812
820
else
813
821
{
822
+ #if WINDOWS_UWP
814
823
SpatialCoordinateSystem sceneOrigin = SpatialGraphInteropPreview . CreateCoordinateSystemForNode ( sceneOriginId ) ;
815
824
SpatialCoordinateSystem worldOrigin = WindowsMixedReality . WindowsMixedRealityUtilities . SpatialCoordinateSystem ;
816
825
@@ -824,8 +833,8 @@ private async Task RunObserverAsync(CancellationToken cancellationToken)
824
833
{
825
834
return null ;
826
835
}
827
- }
828
836
#endif // WINDOWS_UWP
837
+ }
829
838
return result ;
830
839
}
831
840
0 commit comments