Skip to content
This repository has been archived by the owner on Aug 11, 2024. It is now read-only.

Commit

Permalink
Fixed issues around errors when starting and stopping playmode in edi…
Browse files Browse the repository at this point in the history
…tor (#668)

* Fixed issues around errors when starting and stopping playmode in editor

* updated sdk checkout
  • Loading branch information
StephenHodgson authored Sep 28, 2020
1 parent d512062 commit 12e62c6
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,8 @@ public override void Disable()
// Disable any spatial meshes we might have.
foreach (var meshObject in spatialMeshObjects.Values)
{
if (meshObject.GameObject != null)
{
meshObject.GameObject.SetActive(false);
}
Debug.Assert(meshObject.GameObject != null);
meshObject.GameObject.SetActive(false);
}
}

Expand All @@ -152,7 +150,7 @@ public override void Destroy()
meshObject.GameObject.Destroy();
}

spatialMeshObjects.Clear();
Debug.Assert(spatialMeshObjects.Count == 0);

lock (spatialMeshObjectPool)
{
Expand All @@ -161,6 +159,8 @@ public override void Destroy()
var meshObject = spatialMeshObjectPool.Pop();
meshObject.GameObject.Destroy();
}

Debug.Assert(spatialMeshObjectPool.Count == 0);
}
}

Expand Down
10 changes: 1 addition & 9 deletions Runtime/Services/MixedRealityToolkit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -673,15 +673,7 @@ private void Awake()

if (IsInitialized && instance != this)
{
if (Application.isEditor)
{
DestroyImmediate(gameObject);
}
else
{
Destroy(gameObject);
}

gameObject.Destroy();
Debug.LogWarning($"Trying to instantiate a second instance of the {nameof(MixedRealityToolkit)}. Additional Instance was destroyed");
}
else if (!IsInitialized)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,25 +202,22 @@ public override void Destroy()
if (spatialAwarenessParent != null)
{
spatialAwarenessParent.transform.DetachChildren();
spatialAwarenessParent.Destroy();
}

spatialAwarenessParent.Destroy();

// Detach the mesh objects (they are to be cleaned up by the observer) and cleanup the parent
if (meshParent != null)
{
meshParent.transform.DetachChildren();
meshParent.Destroy();
}

meshParent.Destroy();

// Detach the surface objects (they are to be cleaned up by the observer) and cleanup the parent
if (surfaceParent != null)
{
surfaceParent.transform.DetachChildren();
surfaceParent.Destroy();
}

surfaceParent.Destroy();
}

#region Mesh Events
Expand Down

0 comments on commit 12e62c6

Please sign in to comment.