@@ -166,7 +166,10 @@ public override void Enable()
166
166
// Terminate the background thread when we stop in editor.
167
167
cancelToken = cancelTokenSource . Token ;
168
168
169
- task = Task . Run ( ( ) => RunObserverAsync ( cancelToken ) ) ;
169
+ task = Task . Run ( ( ) => RunObserverAsync ( cancelToken ) ) . ContinueWith ( t =>
170
+ {
171
+ Debug . LogError ( $ "{ t . Exception . InnerException . GetType ( ) . Name } : { t . Exception . InnerException . Message } { t . Exception . InnerException . StackTrace } ") ;
172
+ } , TaskContinuationOptions . OnlyOnFaulted ) ;
170
173
#else
171
174
IsEnabled = false ;
172
175
#endif // SCENE_UNDERSTANDING_PRESENT && UNITY_WSA
@@ -180,7 +183,7 @@ public override void Update()
180
183
if ( instantiationQueue . Count > 0 )
181
184
{
182
185
// Make our new objects in batches and tell observers about it
183
- int batchCount = Math . Min ( InstantiationBatchRate , instantiationQueue . Count ) ;
186
+ int batchCount = CreateGameObjects ? Math . Min ( InstantiationBatchRate , instantiationQueue . Count ) : instantiationQueue . Count ;
184
187
185
188
for ( int i = 0 ; i < batchCount ; ++ i )
186
189
{
@@ -313,7 +316,10 @@ public IReadOnlyDictionary<int, SpatialAwarenessSceneObject> SceneObjects
313
316
public void SaveScene ( string filenamePrefix )
314
317
{
315
318
#if WINDOWS_UWP && SCENE_UNDERSTANDING_PRESENT
316
- Task . Run ( ( ) => SaveToFile ( filenamePrefix ) ) ;
319
+ Task . Run ( ( ) => SaveToFile ( filenamePrefix ) ) . ContinueWith ( t =>
320
+ {
321
+ Debug . LogError ( $ "{ t . Exception . InnerException . GetType ( ) . Name } : { t . Exception . InnerException . Message } { t . Exception . InnerException . StackTrace } ") ;
322
+ } , TaskContinuationOptions . OnlyOnFaulted ) ;
317
323
#else // WINDOWS_UWP && SCENE_UNDERSTANDING_PRESENT
318
324
Debug . LogWarning ( "SaveScene() only supported at runtime! Ignoring request." ) ;
319
325
#endif // WINDOWS_UWP && SCENE_UNDERSTANDING_PRESENT
@@ -660,7 +666,7 @@ private async Task RunObserverAsync(CancellationToken cancellationToken)
660
666
661
667
case ObserverState . GetScene :
662
668
observerState = ObserverState . Working ;
663
- if ( CreateGameObjects && instantiationQueue . Count > 0 )
669
+ while ( CreateGameObjects && instantiationQueue . Count > 0 )
664
670
{
665
671
await new WaitForUpdate ( ) ;
666
672
}
@@ -1315,13 +1321,13 @@ private Texture2D OcclusionTexture(byte[] textureBytes)
1315
1321
/// </summary>
1316
1322
private void CleanupInstantiatedSceneObjects ( )
1317
1323
{
1318
- if ( observedObjectParent != null )
1324
+ if ( ObservedObjectParent != null )
1319
1325
{
1320
- int kidCount = observedObjectParent . transform . childCount ;
1326
+ int kidCount = ObservedObjectParent . transform . childCount ;
1321
1327
1322
1328
for ( int i = 0 ; i < kidCount ; ++ i )
1323
1329
{
1324
- UnityEngine . Object . Destroy ( observedObjectParent . transform . GetChild ( i ) . gameObject ) ;
1330
+ UnityEngine . Object . Destroy ( ObservedObjectParent . transform . GetChild ( i ) . gameObject ) ;
1325
1331
}
1326
1332
}
1327
1333
}
0 commit comments