@@ -33,6 +33,11 @@ private float MaxFrameTimeInSeconds
3333 get { return ( MaxFrameTime / 1000 ) ; }
3434 }
3535
36+ /// <summary>
37+ /// Whether to create mesh colliders. If unchecked, mesh colliders will be empty and disabled.
38+ /// </summary>
39+ public bool CreateMeshColliders = true ;
40+
3641 private bool drawProcessedMesh = true ;
3742 // Properties
3843 /// <summary>
@@ -98,10 +103,17 @@ private class MeshData
98103 public readonly Mesh MeshObject = new Mesh ( ) ;
99104
100105 /// <summary>
101- /// The MeshCollider with which this mesh is associated.
106+ /// The MeshCollider with which this mesh is associated. Must be set even if
107+ /// no collision mesh will be created.
102108 /// </summary>
103109 public MeshCollider SpatialCollider = null ;
104110
111+ /// <summary>
112+ /// Whether to create collision mesh. If false, the MeshCollider attached to this
113+ /// object will also be disabled when Commit() is called.
114+ /// </summary>
115+ public bool CreateMeshCollider = false ;
116+
105117 /// <summary>
106118 /// Clears the geometry, but does not clear the mesh.
107119 /// </summary>
@@ -125,7 +137,15 @@ public void Commit()
125137 MeshObject . RecalculateBounds ( ) ;
126138 // The null assignment is required by Unity in order to pick up the new mesh
127139 SpatialCollider . sharedMesh = null ;
128- SpatialCollider . sharedMesh = MeshObject ;
140+ if ( CreateMeshCollider )
141+ {
142+ SpatialCollider . sharedMesh = MeshObject ;
143+ SpatialCollider . enabled = true ;
144+ }
145+ else
146+ {
147+ SpatialCollider . enabled = false ;
148+ }
129149 }
130150 }
131151
@@ -188,6 +208,7 @@ private void AddTriangleToSector(Vector3 sector, Vector3 point1, Vector3 point2,
188208 if ( ! meshSectors . TryGetValue ( sector , out nextSectorData ) )
189209 {
190210 nextSectorData = new MeshData ( ) ;
211+ nextSectorData . CreateMeshCollider = CreateMeshColliders ;
191212
192213 int surfaceObjectIndex = SurfaceObjects . Count ;
193214
0 commit comments