@@ -178,6 +178,10 @@ ObjectModel model = await observer.LoadObjectModelAsync(modelAsBytes);
178
178
The application creates a query to detect instances of that model within a space.
179
179
180
180
``` cs
181
+ #if WINDOWS_UWP || DOTNETWINRT_PRESENT
182
+ #define SPATIALCOORDINATESYSTEM_API_PRESENT
183
+ #endif
184
+
181
185
using Microsoft .Azure .ObjectAnchors ;
182
186
using Microsoft .Azure .ObjectAnchors .SpatialGraph ;
183
187
using Microsoft .Azure .ObjectAnchors .Unity ;
@@ -186,7 +190,7 @@ using UnityEngine;
186
190
// Get the coordinate system.
187
191
SpatialGraphCoordinateSystem ? coordinateSystem = null ;
188
192
189
- #if WINDOWS_UWP
193
+ #if SPATIALCOORDINATESYSTEM_API_PRESENT
190
194
SpatialCoordinateSystem worldOrigin = ObjectAnchorsWorldManager .WorldOrigin ;
191
195
if (worldOrigin != null )
192
196
{
@@ -237,7 +241,7 @@ foreach (ObjectInstance instance in detectedObjects)
237
241
// Supported modes:
238
242
// "LowLatencyCoarsePosition" - Consumes less CPU cycles thus fast to
239
243
// update the state.
240
- // "HighLatencyAccuratePosition" - (Not yet implemented) Consumes more CPU
244
+ // "HighLatencyAccuratePosition" - Uses the device's camera and consumes more CPU
241
245
// cycles thus potentially taking longer
242
246
// time to update the state.
243
247
// "Paused" - Stops to update the state until mode
@@ -257,25 +261,24 @@ In the state changed event, we can query the latest state or dispose an instance
257
261
``` cs
258
262
using Microsoft .Azure .ObjectAnchors ;
259
263
260
- var InstanceChangedHandler = new Windows . Foundation . TypedEventHandler < ObjectInstance , ObjectInstanceChangedEventArgs >(( sender , args ) =>
264
+ void InstanceChangedHandler ( object sender , ObjectInstanceChangedEventArgs args )
261
265
{
262
266
// Try to query the current instance state.
263
- ObjectInstanceState ? state = sender .TryGetCurrentState ();
267
+ ObjectInstanceState state = sender .TryGetCurrentState ();
264
268
265
- if (state . HasValue )
269
+ if (state != null )
266
270
{
267
- // Process latest state via state.Value .
268
- // An object pose includes scale, rotation and translation, applied in
271
+ // Process latest state.
272
+ // An object pose includes rotation and translation, applied in
269
273
// the same order to the object model in the centered coordinate system.
270
274
}
271
275
else
272
276
{
273
277
// This object instance is lost for tracking, and will never be recovered.
274
278
// The caller can detach the Changed event handler from this instance
275
279
// and dispose it.
276
- sender .Dispose ();
277
280
}
278
- });
281
+ }
279
282
```
280
283
281
284
Also, an application can optionally record one or multiple diagnostics sessions for offline debugging.
0 commit comments