public GablePart AddNewPart() { GablePart output = new GablePart(GablePart.Types.Diagonal); output.size = Vector2.one; _parts.Add(output); MarkModified(); return(output); }
public GablePart InsertNewPart(int index) { GablePart output = new GablePart(GablePart.Types.Diagonal); output.size = Vector2.one; _parts.Insert(index, output); MarkModified(); return(output); }
public void RemovePart(GablePart part) { _parts.Remove(part); MarkModified(); }
public override void OnInspectorGUI() { // BuildRSettings settings = BuildRSettings.GetSettings(); Undo.RecordObject(_gable, "Gable Modification"); BuildingEditor.BuildRHeader("Gable"); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Name", GUILayout.Width(80)); string newName = EditorGUILayout.DelayedTextField(_gable.name); if (newName != _gable.name) { BuildingEditorUtils.RenameAsset(_gable, newName); } EditorGUILayout.EndHorizontal(); // EditorGUILayout.BeginHorizontal(); // EditorGUILayout.LabelField("Thickness"); // _gable.thickness = EditorGUILayout.Slider(_gable.thickness, 0.1f, 5); // EditorGUILayout.EndHorizontal(); // EditorGUILayout.BeginHorizontal(); // EditorGUILayout.LabelField("Additional Height"); // _gable.additionalHeight = EditorGUILayout.Slider(_gable.additionalHeight, 0.0f, 10f); // EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Surface"); _gable.surface = EditorGUILayout.ObjectField(_gable.surface, typeof(Surface), false) as Surface; EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Gable Segments"); _gable.segments = EditorGUILayout.IntSlider(_gable.segments, 1, 24); EditorGUILayout.EndHorizontal(); int partCount = _gable.count; EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(string.Format("Gable Parts: {0}", partCount)); if (GUILayout.Button("Add Part", GUILayout.Width(90))) { _gable.AddNewPart(); partCount = _gable.count; } EditorGUILayout.EndHorizontal(); for (int p = 0; p < partCount; p++) { GablePart part = _gable[p]; EditorGUILayout.BeginVertical("Box"); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(string.Format("Part {0}", p + 1)); if (GUILayout.Button("Insert", GUILayout.Width(70))) { _gable.InsertNewPart(p); break; } if (GUILayout.Button("Remove", GUILayout.Width(70))) { _gable.RemovePartAt(p); break;//just kill the loop for now } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Type", GUILayout.Width(50)); part.type = (GablePart.Types)EditorGUILayout.EnumPopup(part.type, GUILayout.Width(90)); EditorGUILayout.Space(); EditorGUILayout.LabelField("Size", GUILayout.Width(50)); Vector2 size = part.size; switch (part.type) { case GablePart.Types.Horizonal: // size.x = EditorGUILayout.DelayedFloatField(size.x); size.x = EditorGUILayout.FloatField("\t", size.x); break; case GablePart.Types.Vertical: size.y = EditorGUILayout.FloatField("\t", size.y); break; default: size = EditorGUILayout.Vector2Field("", size); break; } part.size = size; EditorGUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); _gable[p] = part;//reassign to check for modification } EditorGUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button("Add Part", GUILayout.Width(90))) { _gable.AddNewPart(); } EditorGUILayout.EndHorizontal(); if (GUI.changed) { Repaint(); EditorUtility.SetDirty(_gable); } // DrawDefaultInspector(); }