diff --git a/com.microsoft.mrtk.graphicstools.unity/Runtime/MeshOutline/MeshOutlineHierarchy.cs b/com.microsoft.mrtk.graphicstools.unity/Runtime/MeshOutline/MeshOutlineHierarchy.cs
index c453e019..ec5555eb 100644
--- a/com.microsoft.mrtk.graphicstools.unity/Runtime/MeshOutline/MeshOutlineHierarchy.cs
+++ b/com.microsoft.mrtk.graphicstools.unity/Runtime/MeshOutline/MeshOutlineHierarchy.cs
@@ -39,6 +39,34 @@ private void Awake()
}
}
+ ///
+ /// Enables all child mesh outlines.
+ ///
+ private void OnEnable()
+ {
+ foreach (var meshOutline in meshOutlines)
+ {
+ if (meshOutline != null)
+ {
+ meshOutline.enabled = true;
+ }
+ }
+ }
+
+ ///
+ /// Disables all child mesh outlines.
+ ///
+ private void OnDisable()
+ {
+ foreach (var meshOutline in meshOutlines)
+ {
+ if (meshOutline != null)
+ {
+ meshOutline.enabled = false;
+ }
+ }
+ }
+
///
/// Removes any components this component has created.
///
diff --git a/com.microsoft.mrtk.graphicstools.unity/Runtime/MeshOutline/MeshSmoother.cs b/com.microsoft.mrtk.graphicstools.unity/Runtime/MeshOutline/MeshSmoother.cs
index dd9fddf7..8076298c 100644
--- a/com.microsoft.mrtk.graphicstools.unity/Runtime/MeshOutline/MeshSmoother.cs
+++ b/com.microsoft.mrtk.graphicstools.unity/Runtime/MeshOutline/MeshSmoother.cs
@@ -128,7 +128,10 @@ private void Awake()
///
private void OnDestroy()
{
- meshFilter.sharedMesh = originalMesh;
+ if (originalMesh != null)
+ {
+ meshFilter.sharedMesh = originalMesh;
+ }
MeshReference meshReference;
var sharedMesh = meshFilter.sharedMesh;
@@ -160,44 +163,51 @@ private bool AcquirePreprocessedMesh(out UnityEngine.Mesh mesh)
meshFilter = GetComponent();
}
- var sharedMesh = meshFilter.sharedMesh;
+ // No mesh filter, mesh cannot be processed, so return a null mesh.
+ if (meshFilter == null)
+ {
+ mesh = null;
- MeshReference meshReference;
+ return true;
+ }
+
+ originalMesh = meshFilter.sharedMesh;
- if (sharedMesh != null)
+ // No mesh , mesh cannot be processed, so return a null mesh.
+ if (originalMesh == null)
{
- // A non-readable mesh cannot be processed, so return a null mesh.
- if (sharedMesh.isReadable == false)
- {
- Debug.LogWarning($"Mesh smoothing failed because {sharedMesh.name} is not readable. Check \"Read/Write Enabled\" in the mesh's import settings.");
+ mesh = null;
- mesh = null;
+ return true;
+ }
- return true;
- }
+ // A non-readable mesh cannot be processed, so return a null mesh.
+ if (originalMesh.isReadable == false)
+ {
+ Debug.LogWarning($"Mesh smoothing failed because {originalMesh.name} is not readable. Check \"Read/Write Enabled\" in the mesh's import settings.");
- // If this mesh has already been processed, apply the preprocessed mesh and increment the reference count.
- if (processedMeshes.TryGetValue(sharedMesh, out meshReference))
- {
- meshReference.Increment();
- mesh = meshReference.Mesh;
- meshFilter.mesh = mesh;
+ mesh = null;
- return true;
- }
+ return true;
}
- originalMesh = meshFilter.sharedMesh;
+ MeshReference meshReference;
+
+ // If this mesh has already been processed, apply the preprocessed mesh and increment the reference count.
+ if (processedMeshes.TryGetValue(originalMesh, out meshReference))
+ {
+ meshReference.Increment();
+ mesh = meshReference.Mesh;
+ meshFilter.mesh = mesh;
+
+ return true;
+ }
// Clone the mesh, and create a mesh reference which can be keyed off either the original mesh or cloned mesh.
mesh = meshFilter.mesh;
meshReference = new MeshReference(mesh);
processedMeshes[mesh] = meshReference;
-
- if (sharedMesh != null)
- {
- processedMeshes[sharedMesh] = meshReference;
- }
+ processedMeshes[originalMesh] = meshReference;
return false;
}
diff --git a/com.microsoft.mrtk.graphicstools.unity/package.json b/com.microsoft.mrtk.graphicstools.unity/package.json
index e830e0e7..be13ba7f 100644
--- a/com.microsoft.mrtk.graphicstools.unity/package.json
+++ b/com.microsoft.mrtk.graphicstools.unity/package.json
@@ -1,6 +1,6 @@
{
"name": "com.microsoft.mrtk.graphicstools.unity",
- "version": "0.4.16",
+ "version": "0.4.17",
"displayName": "MRTK Graphics Tools",
"description": "Graphics tools and components for developing Mixed Reality applications in Unity.",
"msftFeatureCategory": "MRTK3",