Skip to content

Commit

Permalink
FoxMeshes mesh groups are now updated when changes are made in FoxMod…
Browse files Browse the repository at this point in the history
…elEditor.
  • Loading branch information
BobDoleOwndU committed Jun 15, 2021
1 parent 458b348 commit 86f60dc
Showing 1 changed file with 48 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using FmdlStudio.Scripts.MonoBehaviours;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;

Expand Down Expand Up @@ -72,6 +73,14 @@ public override void OnInspectorGUI()
foxModel.meshGroups[i + 1] = new FoxMeshGroup();

serializedObject.Update();

List<FoxMesh> foxMeshes = GetFoxMeshes(foxModel.gameObject.transform);

foreach(FoxMesh f in foxMeshes)
{
if (f.meshGroup > i)
f.meshGroup++;
} //foreach
} //if

if (GUILayout.Button("-", GUILayout.Width(25)))
Expand All @@ -87,6 +96,14 @@ public override void OnInspectorGUI()
meshGroupsLength--;
foxModel.meshGroups = SetArraySize(foxModel.meshGroups, meshGroupsLength);
serializedObject.Update();

List<FoxMesh> foxMeshes = GetFoxMeshes(foxModel.gameObject.transform);

foreach (FoxMesh f in foxMeshes)
{
if (f.meshGroup > i)
f.meshGroup--;
} //foreach
} //if

if (i != 0)
Expand All @@ -103,6 +120,15 @@ public override void OnInspectorGUI()
else if(foxModel.meshGroups[j].parent == i - 1)
foxModel.meshGroups[j].parent++;

List<FoxMesh> foxMeshes = GetFoxMeshes(foxModel.gameObject.transform);

foreach (FoxMesh f in foxMeshes)
{
if (f.meshGroup == i)
f.meshGroup--;
else if (f.meshGroup == i - 1)
f.meshGroup++;
} //foreach
} //if
} //if

Expand All @@ -119,10 +145,20 @@ public override void OnInspectorGUI()
foxModel.meshGroups[j].parent++;
else if (foxModel.meshGroups[j].parent == i + 1)
foxModel.meshGroups[j].parent--;

List<FoxMesh> foxMeshes = GetFoxMeshes(foxModel.gameObject.transform);

foreach (FoxMesh f in foxMeshes)
{
if (f.meshGroup == i)
f.meshGroup++;
else if (f.meshGroup == i + 1)
f.meshGroup--;
} //foreach
} //if
} //if
GUILayout.EndHorizontal();

GUILayout.EndHorizontal();
} //if
} //for
} //if
Expand All @@ -137,5 +173,16 @@ private T[] SetArraySize<T>(T[] array, int newLength)

return newArray;
} //SetArraySize

private List<FoxMesh> GetFoxMeshes(Transform transform)
{
List<FoxMesh> foxMeshes = new List<FoxMesh>(0);

foreach(Transform t in transform)
if(t.gameObject.GetComponent<FoxMesh>())
foxMeshes.Add(t.gameObject.GetComponent<FoxMesh>());

return foxMeshes;
} //GetFoxMeshes
} //class
} //namespace

0 comments on commit 86f60dc

Please sign in to comment.