diff --git a/unity/Runtime/Components/Shapes/MjMeshFilter.cs b/unity/Runtime/Components/Shapes/MjMeshFilter.cs index c91f7a87..83f4963d 100644 --- a/unity/Runtime/Components/Shapes/MjMeshFilter.cs +++ b/unity/Runtime/Components/Shapes/MjMeshFilter.cs @@ -48,6 +48,12 @@ public class MjMeshFilter : MonoBehaviour { throw new ArgumentException("Unsupported geom shape detected"); } + if(_geom.ShapeType == MjShapeComponent.ShapeTypes.Mesh) { + MjMeshShape meshShape = _geom.Shape as MjMeshShape; + _meshFilter.sharedMesh = meshShape.Mesh; + return; + } + DisposeCurrentMesh(); var mesh = new Mesh(); @@ -73,7 +79,7 @@ public class MjMeshFilter : MonoBehaviour { // Dynamically created meshes with no references are only disposed automatically on scene changes. // This prevents resource leaks in case the host environment doesn't reload scenes. private void DisposeCurrentMesh() { - if (_meshFilter.sharedMesh != null) { + if (_meshFilter.sharedMesh != null && _geom.ShapeType != MjShapeComponent.ShapeTypes.Mesh) { #if UNITY_EDITOR DestroyImmediate(_meshFilter.sharedMesh); #else