12
12
using Unity . Profiling ;
13
13
using Unity . XR . WindowsMR ;
14
14
using 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
15
27
#endif // WMR_2_7_0_OR_NEWER || WMR_4_4_2_OR_NEWER || WMR_5_2_2_OR_NEWER
16
28
17
29
namespace Microsoft . MixedReality . Toolkit . XRSDK . WindowsMixedReality
@@ -172,18 +184,18 @@ public override void Update()
172
184
centerEye = InputDevices . GetDeviceAtXRNode ( XRNode . CenterEye ) ;
173
185
if ( ! centerEye . isValid )
174
186
{
175
- Service ? . EyeGazeProvider ? . UpdateEyeTrackingStatus ( this , false ) ;
187
+ UpdateEyeTrackingCalibrationStatus ( false ) ;
176
188
return ;
177
189
}
178
190
}
179
191
180
192
if ( ! centerEye . TryGetFeatureValue ( WindowsMRUsages . EyeGazeAvailable , out bool gazeAvailable ) || ! gazeAvailable )
181
193
{
182
- Service ? . EyeGazeProvider ? . UpdateEyeTrackingStatus ( this , false ) ;
194
+ UpdateEyeTrackingCalibrationStatus ( false ) ;
183
195
return ;
184
196
}
185
197
186
- Service ? . EyeGazeProvider ? . UpdateEyeTrackingStatus ( this , true ) ;
198
+ UpdateEyeTrackingCalibrationStatus ( true ) ;
187
199
188
200
if ( centerEye . TryGetFeatureValue ( WindowsMRUsages . EyeGazeTracked , out bool gazeTracked )
189
201
&& gazeTracked
@@ -204,6 +216,28 @@ public override void Update()
204
216
}
205
217
}
206
218
}
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
+ }
207
241
#endif // WMR_2_7_0_OR_NEWER || WMR_4_4_2_OR_NEWER || WMR_5_2_2_OR_NEWER
208
242
}
209
243
}
0 commit comments