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); } } } }
private void HandleConstraintControllerGUI(ElementaryConstraintController controller, GUISkin skin) { var controllerType = controller.GetControllerType(); var controllerTypeTag = controllerType.ToString().Substring(0, 1); string dimString = "[" + GUI.AddColorTag(controllerTypeTag, controllerType == Constraint.ControllerType.Rotational ? Color.Lerp(UnityEngine.GUI.color, Color.red, 0.75f) : Color.Lerp(UnityEngine.GUI.color, Color.green, 0.75f)) + "] "; if (GUI.Foldout(Selected(SelectedFoldout.Controller, controllerTypeTag + ConstraintUtils.FindName(controller)), GUI.MakeLabel(dimString + ConstraintUtils.FindName(controller), true), skin, OnFoldoutStateChange)) { using (new GUI.Indent(12)) { controller.Enable = GUI.Toggle(GUI.MakeLabel("Enable", controller.Enable), controller.Enable, skin.button, skin.label); BaseEditor <ElementaryConstraint> .Update(controller, controller, skin); } } }
public override void OnPostTargetMembersGUI(GUISkin skin) { GUI.Separator(); GUIStyle dragDropFieldStyle = new GUIStyle(skin.textArea); dragDropFieldStyle.alignment = TextAnchor.MiddleCenter; dragDropFieldStyle.richText = true; Rect dropArea = new Rect(); GUILayout.BeginHorizontal(); { GUILayout.Label(GUI.MakeLabel("Assign Shape Material [" + GUI.AddColorTag("drop area", Color.Lerp(Color.green, Color.black, 0.4f)) + "]", false, "Assigns dropped shape material to all shapes in this rigid body."), dragDropFieldStyle, GUILayout.Height(22)); dropArea = GUILayoutUtility.GetLastRect(); bool resetMaterials = GUILayout.Button(GUI.MakeLabel("Reset", false, "Reset shapes material to null."), skin.button, GUILayout.Width(42)) && EditorUtility.DisplayDialog("Reset shape materials", "Reset all shapes material to default [null]?", "OK", "Cancel"); if (resetMaterials) { AssignShapeMaterialToAllShapes(null); } } GUILayout.EndHorizontal(); GUI.HandleDragDrop <ShapeMaterial>(dropArea, Event.current, (shapeMaterial) => { AssignShapeMaterialToAllShapes(shapeMaterial); }); GUI.Separator(); OnShapeListGUI(skin); OnConstraintListGUI(skin); }
private void OnConstraintListGUI(GUISkin skin) { if (m_constraints.Count == 0) { return; } GUI.Separator(); if (!GUI.Foldout(EditorData.Instance.GetData(RigidBody, "Constraints"), GUI.MakeLabel("Constraints", true), skin)) { return; } using (new GUI.Indent(12)) { foreach (var constraint in m_constraints) { GUI.Separator(); if (!GUI.Foldout(EditorData.Instance.GetData(RigidBody, constraint.GetInstanceID().ToString()), GUI.MakeLabel("[" + GUI.AddColorTag(constraint.Type.ToString(), Color.Lerp(Color.magenta, Color.black, 0.4f)) + "] " + constraint.name), skin)) { continue; } GUI.Separator(); var constraintTool = new ConstraintTool(constraint) { OnFoldoutStateChange = state => EditorUtility.SetDirty(RigidBody) }; using (new GUI.Indent(12)) { constraintTool.OnPreTargetMembersGUI(skin); } } } }
protected override string GetNodeTypeString(RouteNode node) { var cableNode = node as CableRouteNode; return(GUI.AddColorTag(cableNode.Type.ToString().SplitCamelCase(), GetColor(cableNode))); }