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

Fixed issues around errors when starting and stopping playmode in editor #668

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Submodules/SDK
Submodule SDK updated from a419b3 to 70688a
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
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