public override void OnInspectorGUI() { base.OnInspectorGUI(); EnsureObjects(); if (GUILayout.Button("Centralize")) { _polygonWithHoles.Centralize(); } if (_polygonWithHoles.polygonMode == Polygon.PolygonMode.Simplified) { if (GUILayout.Button("Non-Simplify")) { _polygonWithHoles.ToDefault(); } } else { if (GUILayout.Button("Simplify")) { _polygonWithHoles.Simplify(); } } if (_polygonWithHoles.polygonMode == Polygon.PolygonMode.Triangulated) { if (GUILayout.Button("Non-Triangulate")) { _polygonWithHoles.ToDefault(); } } else { if (GUILayout.Button("Triangulate")) { _polygonWithHoles.Triangulate(); } } if (GUILayout.Button("Save")) { PolygonWithHolesSetup.Record(_polygonWithHoles); } _setup = (PolygonWithHolesSetup)EditorGUILayout.ObjectField("Setup", _setup, typeof(PolygonWithHolesSetup)); if (GUILayout.Button("Load")) { _polygonWithHoles.Load(_setup); _polygonWithHoles.ToDefault(); } }
public void Load(PolygonWithHolesSetup setup) { DestroyImmediate(polygon.gameObject); polygon = Polygon.NewPolygon(setup.vertices, setup.polygonPosition, setup.polygonRotation, transform); while (holes.Count > 0) { var hole = holes[0]; DestroyImmediate(hole.gameObject); holes.RemoveAt(0); } while (holes.Count < setup.holes.Count) { var index = holes.Count; var name = string.Format("Hole ({0})", index); var hole = Polygon.NewPolygon(setup.holes[index].vertices, setup.holePositions[index], setup.holeRotations[index], transform, name); hole.drawVertex = false; hole.drawVertexIndex = false; holes.Add(hole); } }