private void OnShapeListGUI(GUISkin skin) { if (!GUI.Foldout(EditorData.Instance.GetData(RigidBody, "Shapes"), GUI.MakeLabel("Shapes", true), skin)) { return; } Shape[] shapes = RigidBody.GetComponentsInChildren <Shape>(); if (shapes.Length == 0) { using (new GUI.Indent(12)) GUILayout.Label(GUI.MakeLabel("Empty", true), skin.label); return; } using (new GUI.Indent(12)) { foreach (var shape in shapes) { GUI.Separator(); if (!GUI.Foldout(EditorData.Instance.GetData(RigidBody, shape.GetInstanceID().ToString()), GUI.MakeLabel("[" + GUI.AddColorTag(shape.GetType().Name, Color.Lerp(Color.green, Color.black, 0.4f)) + "] " + shape.name), skin)) { continue; } GUI.Separator(); using (new GUI.Indent(12)) { Undo.RecordObjects(shape.GetUndoCollection(), "Shape"); shape.enabled = GUI.Toggle(GUI.MakeLabel("Enable"), shape.enabled, skin.button, skin.label); if (shape is AGXUnity.Collide.Mesh) { GUI.Separator(); var newMeshSource = GUI.ShapeMeshSourceGUI((shape as AGXUnity.Collide.Mesh).SourceObjects.FirstOrDefault(), skin); if (newMeshSource != null) { (shape as AGXUnity.Collide.Mesh).SetSourceObject(newMeshSource); } } GUI.Separator(); BaseEditor <Shape> .Update(shape, shape, skin); } } } }
public override void OnPreTargetMembersGUI() { base.OnPreTargetMembersGUI(); var sourceObjects = Mesh.SourceObjects; var singleSource = sourceObjects.FirstOrDefault(); if (IsMultiSelect) { var undoCollection = new List <Object>(); foreach (var target in GetTargets <AGXUnity.Collide.Mesh>()) { if (target != null) { undoCollection.AddRange(target.GetUndoCollection()); } } Undo.RecordObjects(undoCollection.ToArray(), "Mesh source"); } else { Undo.RecordObjects(Mesh.GetUndoCollection(), "Mesh source"); } var newSingleSource = GUI.ShapeMeshSourceGUI(singleSource, InspectorEditor.Skin); if (newSingleSource != null) { if (IsMultiSelect) { foreach (var target in GetTargets <AGXUnity.Collide.Mesh>()) { if (target != null) { target.SetSourceObject(newSingleSource); } } } else { Mesh.SetSourceObject(newSingleSource); } } GUI.Separator(); }
public override void OnPreTargetMembersGUI(GUISkin skin) { base.OnPreTargetMembersGUI(skin); var sourceObjects = Mesh.SourceObjects; var singleSource = sourceObjects.FirstOrDefault(); Undo.RecordObjects(Mesh.GetUndoCollection(), "Mesh source"); var newSingleSource = GUI.ShapeMeshSourceGUI(singleSource, skin); if (newSingleSource != null) { Mesh.SetSourceObject(newSingleSource); } GUI.Separator(); }