1212using Unity . Profiling ;
1313using Unity . XR . WindowsMR ;
1414using UnityEngine . XR ;
15+
16+ #if WINDOWS_UWP
17+ using Windows . Perception ;
18+ using Windows . Perception . People ;
19+ using Windows . Perception . Spatial ;
20+ using Windows . UI . Input . Spatial ;
21+ #elif UNITY_WSA && DOTNETWINRT_PRESENT
22+ using Microsoft . Windows . Perception ;
23+ using Microsoft . Windows . Perception . People ;
24+ using Microsoft . Windows . Perception . Spatial ;
25+ using Microsoft . Windows . UI . Input . Spatial ;
26+ #endif
1527#endif // WMR_2_7_0_OR_NEWER || WMR_4_4_2_OR_NEWER || WMR_5_2_2_OR_NEWER
1628
1729namespace Microsoft . MixedReality . Toolkit . XRSDK . WindowsMixedReality
@@ -172,18 +184,18 @@ public override void Update()
172184 centerEye = InputDevices . GetDeviceAtXRNode ( XRNode . CenterEye ) ;
173185 if ( ! centerEye . isValid )
174186 {
175- Service ? . EyeGazeProvider ? . UpdateEyeTrackingStatus ( this , false ) ;
187+ UpdateEyeTrackingCalibrationStatus ( false ) ;
176188 return ;
177189 }
178190 }
179191
180192 if ( ! centerEye . TryGetFeatureValue ( WindowsMRUsages . EyeGazeAvailable , out bool gazeAvailable ) || ! gazeAvailable )
181193 {
182- Service ? . EyeGazeProvider ? . UpdateEyeTrackingStatus ( this , false ) ;
194+ UpdateEyeTrackingCalibrationStatus ( false ) ;
183195 return ;
184196 }
185197
186- Service ? . EyeGazeProvider ? . UpdateEyeTrackingStatus ( this , true ) ;
198+ UpdateEyeTrackingCalibrationStatus ( true ) ;
187199
188200 if ( centerEye . TryGetFeatureValue ( WindowsMRUsages . EyeGazeTracked , out bool gazeTracked )
189201 && gazeTracked
@@ -204,6 +216,28 @@ public override void Update()
204216 }
205217 }
206218 }
219+
220+ private void UpdateEyeTrackingCalibrationStatus ( bool defaultValue )
221+ {
222+ #if WINDOWS_UWP || ( UNITY_WSA && DOTNETWINRT_PRESENT )
223+ SpatialCoordinateSystem worldOrigin = Toolkit . WindowsMixedReality . WindowsMixedRealityUtilities . SpatialCoordinateSystem ;
224+ if ( worldOrigin != null )
225+ {
226+ SpatialPointerPose pointerPose = SpatialPointerPose . TryGetAtTimestamp ( worldOrigin , PerceptionTimestampHelper . FromHistoricalTargetTime ( DateTimeOffset . Now ) ) ;
227+ if ( pointerPose != null )
228+ {
229+ EyesPose eyes = pointerPose . Eyes ;
230+ if ( eyes != null )
231+ {
232+ Service ? . EyeGazeProvider ? . UpdateEyeTrackingStatus ( this , eyes . IsCalibrationValid ) ;
233+ return ;
234+ }
235+ }
236+ }
237+ #endif // WINDOWS_UWP || (UNITY_WSA && DOTNETWINRT_PRESENT)
238+
239+ Service ? . EyeGazeProvider ? . UpdateEyeTrackingStatus ( this , defaultValue ) ;
240+ }
207241#endif // WMR_2_7_0_OR_NEWER || WMR_4_4_2_OR_NEWER || WMR_5_2_2_OR_NEWER
208242 }
209243}
0 commit comments