protected void ControlPointAdded(int index) { var group = InsertNewParticleGroup(path.GetName(index), index); }
private void DrawControlPointInspector() { GUI.enabled = selectedCount > 0; EditorGUILayout.BeginVertical(); GUILayout.Box("", ObiEditorUtils.GetSeparatorLineStyle()); // tangent mode: EditorGUI.showMixedValue = false; var mode = ObiWingedPoint.TangentMode.Free; bool firstSelected = true; for (int i = 0; i < path.ControlPointCount; ++i) { if (selectedStatus[i]) { if (firstSelected) { mode = path.points[i].tangentMode; firstSelected = false; } else if (mode != path.points[i].tangentMode) { EditorGUI.showMixedValue = true; break; } } } EditorGUI.BeginChangeCheck(); var newMode = (ObiWingedPoint.TangentMode)EditorGUILayout.EnumPopup("Tangent mode", mode, GUI.skin.FindStyle("DropDown"), GUILayout.MinWidth(94)); EditorGUI.showMixedValue = false; if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(target, "Change control points mode"); for (int i = 0; i < path.ControlPointCount; ++i) { if (selectedStatus[i]) { var wp = path.points[i]; wp.tangentMode = newMode; path.points[i] = wp; } } path.FlushEvents(); needsRepaint = true; } // thickness: EditorGUI.showMixedValue = false; float thickness = 0; firstSelected = true; for (int i = 0; i < path.ControlPointCount; ++i) { if (selectedStatus[i]) { if (firstSelected) { thickness = path.thicknesses[i]; firstSelected = false; } else if (!Mathf.Approximately(thickness, path.thicknesses[i])) { EditorGUI.showMixedValue = true; break; } } } EditorGUI.BeginChangeCheck(); thickness = EditorGUILayout.FloatField("Thickness", thickness, GUILayout.MinWidth(94)); EditorGUI.showMixedValue = false; if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(target, "Change control point thickness"); for (int i = 0; i < path.ControlPointCount; ++i) { if (selectedStatus[i]) { path.thicknesses[i] = Mathf.Max(0, thickness); } } path.FlushEvents(); needsRepaint = true; } // mass: EditorGUI.showMixedValue = false; float mass = 0; firstSelected = true; for (int i = 0; i < path.ControlPointCount; ++i) { if (selectedStatus[i]) { if (firstSelected) { mass = path.masses[i]; firstSelected = false; } else if (!Mathf.Approximately(mass, path.masses[i])) { EditorGUI.showMixedValue = true; break; } } } EditorGUI.BeginChangeCheck(); mass = EditorGUILayout.FloatField("Mass", mass, GUILayout.MinWidth(94)); EditorGUI.showMixedValue = false; if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(target, "Change control point mass"); for (int i = 0; i < path.ControlPointCount; ++i) { if (selectedStatus[i]) { path.masses[i] = mass; } } path.FlushEvents(); needsRepaint = true; } if (useOrientation) { // rotational mass: EditorGUI.showMixedValue = false; float rotationalMass = 0; firstSelected = true; for (int i = 0; i < path.ControlPointCount; ++i) { if (selectedStatus[i]) { if (firstSelected) { rotationalMass = path.rotationalMasses[i]; firstSelected = false; } else if (!Mathf.Approximately(rotationalMass, path.rotationalMasses[i])) { EditorGUI.showMixedValue = true; break; } } } EditorGUI.BeginChangeCheck(); rotationalMass = EditorGUILayout.FloatField("Rotational mass", rotationalMass, GUILayout.MinWidth(94)); EditorGUI.showMixedValue = false; if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(target, "Change control point rotational mass"); for (int i = 0; i < path.ControlPointCount; ++i) { if (selectedStatus[i]) { path.rotationalMasses[i] = rotationalMass; } } path.FlushEvents(); needsRepaint = true; } } // phase: EditorGUI.showMixedValue = false; int phase = 0; firstSelected = true; for (int i = 0; i < path.ControlPointCount; ++i) { if (selectedStatus[i]) { if (firstSelected) { phase = path.phases[i]; firstSelected = false; } else if (!Mathf.Approximately(phase, path.phases[i])) { EditorGUI.showMixedValue = true; break; } } } EditorGUI.BeginChangeCheck(); phase = EditorGUILayout.IntField("Phase", phase, GUILayout.MinWidth(94)); EditorGUI.showMixedValue = false; if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(target, "Change control point phase"); for (int i = 0; i < path.ControlPointCount; ++i) { if (selectedStatus[i]) { path.phases[i] = phase; } } path.FlushEvents(); needsRepaint = true; } // color: EditorGUI.showMixedValue = false; Color color = Color.white; firstSelected = true; for (int i = 0; i < path.ControlPointCount; ++i) { if (selectedStatus[i]) { if (firstSelected) { color = path.colors[i]; firstSelected = false; } else if (color != path.colors[i]) { EditorGUI.showMixedValue = true; break; } } } EditorGUI.BeginChangeCheck(); color = EditorGUILayout.ColorField("Color", color, GUILayout.MinWidth(94)); EditorGUI.showMixedValue = false; if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(target, "Change control point color"); for (int i = 0; i < path.ControlPointCount; ++i) { if (selectedStatus[i]) { path.colors[i] = color; } } path.FlushEvents(); needsRepaint = true; } // name: EditorGUI.showMixedValue = false; string name = ""; firstSelected = true; for (int i = 0; i < path.ControlPointCount; ++i) { if (selectedStatus[i]) { if (firstSelected) { name = path.GetName(i); firstSelected = false; } else if (name != path.GetName(i)) { EditorGUI.showMixedValue = true; break; } } } EditorGUI.BeginChangeCheck(); name = EditorGUILayout.DelayedTextField("Name", name, GUILayout.MinWidth(94)); EditorGUI.showMixedValue = false; if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(target, "Change control point name"); for (int i = 0; i < path.ControlPointCount; ++i) { if (selectedStatus[i]) { path.SetName(i, name); } } path.FlushEvents(); needsRepaint = true; } EditorGUILayout.EndVertical(); GUI.enabled = true; }