@@ -159,6 +159,11 @@ bool SelectionMeshDirty()
159
159
160
160
void GenerateSelectionMesh ( )
161
161
{
162
+ if ( cloth . vertices . Length == 0 )
163
+ {
164
+ return ;
165
+ }
166
+
162
167
SkinnedMeshRenderer smr = cloth . GetComponent < SkinnedMeshRenderer > ( ) ;
163
168
Vector3 [ ] vertices = cloth . vertices ;
164
169
@@ -308,6 +313,11 @@ void AssignColorsToMeshArray(Color[] colors, Mesh[] meshArray)
308
313
309
314
void SetupSelectionMeshColors ( )
310
315
{
316
+ if ( cloth . vertices . Length == 0 )
317
+ {
318
+ return ;
319
+ }
320
+
311
321
ClothSkinningCoefficient [ ] coefficients = cloth . coefficients ;
312
322
int length = coefficients . Length ;
313
323
Color [ ] colors = new Color [ length * m_MeshVerticesPerSelectionVertex ] ;
@@ -349,6 +359,11 @@ void SetupSelectionMeshColors()
349
359
350
360
void SetupSelectedMeshColors ( )
351
361
{
362
+ if ( cloth . vertices . Length == 0 )
363
+ {
364
+ return ;
365
+ }
366
+
352
367
int length = cloth . coefficients . Length ;
353
368
Color [ ] colors = new Color [ length * m_MeshVerticesPerSelectionVertex ] ;
354
369
for ( int i = 0 ; i < length ; i ++ )
@@ -944,6 +959,12 @@ private void OnPreSceneGUICallback(SceneView sceneView)
944
959
if ( state . ToolMode == ( ToolMode ) ( - 1 ) )
945
960
state . ToolMode = ToolMode . Select ;
946
961
962
+ if ( m_Selection == null )
963
+ {
964
+ GenerateSelectionMesh ( ) ;
965
+ SetupSelectedMeshColors ( ) ;
966
+ }
967
+
947
968
ClothSkinningCoefficient [ ] coefficients = cloth . coefficients ;
948
969
if ( m_Selection . Length != coefficients . Length && m_Selection . Length != s_MaxVertices )
949
970
// Recreate selection if underlying mesh has changed.
0 commit comments