Exemple #1
0
        public void OnInspectorGUI(GUISkin skin)
        {
            using (GUI.AlignBlock.Center)
                GUILayout.Label(GUI.MakeLabel("AgXUnity Editor Settings", 24, true), skin.label);

            GUI.Separator3D();

            // Debug render manager.
            {
                using (GUI.AlignBlock.Center)
                    GUILayout.Label(GUI.MakeLabel("Debug render manager", 16, true), skin.label);
            }

            // BuiltInToolsTool settings GUI.
            {
                using (GUI.AlignBlock.Center)
                    GUILayout.Label(GUI.MakeLabel("Built in tools", 16, true), skin.label);

                GUI.Separator();

                HandleKeyHandlerGUI(GUI.MakeLabel("Select game object"), BuiltInToolsTool_SelectGameObjectKeyHandler, skin);
                HandleKeyHandlerGUI(GUI.MakeLabel("Select rigid body game object"), BuiltInToolsTool_SelectRigidBodyKeyHandler, skin);
                HandleKeyHandlerGUI(GUI.MakeLabel("Pick handler (scene view)"), BuiltInToolsTool_PickHandlerKeyHandler, skin);
            }

            GUI.Separator3D();
        }
Exemple #2
0
        protected override bool OverrideOnInspectorGUI(CableProperties properties, GUISkin skin)
        {
            if (properties == null)
            {
                return(true);
            }

            Undo.RecordObject(properties, "Cable properties");

            using (GUI.AlignBlock.Center)
                GUILayout.Label(GUI.MakeLabel("Cable Properties", true), skin.label);

            GUI.Separator();

            using (new GUI.Indent(12)) {
                foreach (CableProperties.Direction dir in CableProperties.Directions)
                {
                    OnPropertyGUI(dir, properties, skin);
                    GUI.Separator();
                }
            }

            if (UnityEngine.GUI.changed)
            {
                EditorUtility.SetDirty(properties);
            }

            return(true);
        }
Exemple #3
0
        public override void OnPreTargetMembersGUI(GUISkin skin)
        {
            // Possible undo performed that deleted the constraint. Remove us.
            if (Constraint == null)
            {
                PerformRemoveFromParent();
                return;
            }

            GUILayout.Label(GUI.MakeLabel(Constraint.Type.ToString(), 24, true), GUI.Align(skin.label, TextAnchor.MiddleCenter));
            GUI.Separator();

            // Render AttachmentPair GUI.
            base.OnPreTargetMembersGUI(skin);

            GUI.Separator();

            Constraint.CollisionsState = ConstraintCollisionsStateGUI(Constraint.CollisionsState, skin);
            Constraint.SolveType       = ConstraintSolveTypeGUI(Constraint.SolveType, skin);

            GUI.Separator();

            Constraint.ConnectedFrameNativeSyncEnabled = ConstraintConnectedFrameSyncGUI(Constraint.ConnectedFrameNativeSyncEnabled, skin);

            GUI.Separator();

            ConstraintRowsGUI(skin);
        }
        public override void OnPreTargetMembersGUI(GUISkin skin)
        {
            bool toggleDisableCollisions = false;

            GUILayout.BeginHorizontal();
            {
                GUI.ToolsLabel(skin);

                using (GUI.ToolButtonData.ColorBlock) {
                    toggleDisableCollisions = GUI.ToolButton(GUI.Symbols.DisableCollisionsTool, DisableCollisionsTool, "Disable collisions against other objects", skin);
                }
            }
            GUILayout.EndHorizontal();

            if (DisableCollisionsTool)
            {
                GetChild <DisableCollisionsTool>().OnInspectorGUI(skin);

                GUI.Separator();
            }

            if (!EditorApplication.isPlaying)
            {
                RouteGUI(skin);
            }

            if (toggleDisableCollisions)
            {
                DisableCollisionsTool = !DisableCollisionsTool;
            }
        }
Exemple #5
0
        private void HandleConstraintRowsGUI(ConstraintUtils.ConstraintRow[] rows, InvokeWrapper[] wrappers, GUISkin skin)
        {
            foreach (InvokeWrapper wrapper in wrappers)
            {
                if (wrapper.HasAttribute <HideInInspector>())
                {
                    continue;
                }

                GUILayout.BeginHorizontal();
                {
                    GUILayout.Label(GUI.MakeLabel(wrapper.Member.Name), skin.label, GUILayout.MinWidth(74));
                    GUILayout.FlexibleSpace();
                    GUILayout.BeginVertical();
                    {
                        for (int i = 0; i < 3; ++i)
                        {
                            using (new BeginConstraintRowGUI(rows[i], wrapper)) {
                                GUILayout.BeginHorizontal();
                                {
                                    HandleConstraintRowType(rows[i], i, wrapper, skin);
                                }
                                GUILayout.EndHorizontal();
                            }
                        }
                    }
                    GUILayout.EndVertical();
                }
                GUILayout.EndHorizontal();

                GUI.Separator();
            }
        }
Exemple #6
0
        protected override void OnPreFrameGUI(CableRouteNode node, GUISkin skin)
        {
            using (new GUI.Indent(12)) {
                node.Type = (Cable.NodeType)EditorGUILayout.EnumPopup(GUI.MakeLabel("Type"), node.Type, skin.button);

                GUI.Separator();
            }
        }
Exemple #7
0
        public void ConstraintRowsGUI(GUISkin skin)
        {
            try {
                ConstraintUtils.ConstraintRowParser constraintRowParser = ConstraintUtils.ConstraintRowParser.Create(Constraint);

                InvokeWrapper[] memberWrappers = InvokeWrapper.FindFieldsAndProperties(null, typeof(ElementaryConstraintRowData));
                if (constraintRowParser.HasTranslationalRows)
                {
                    if (GUI.Foldout(Selected(SelectedFoldout.OrdinaryElementaryTranslational), GUI.MakeLabel("Translational properties </b>(along constraint axis)<b>", true), skin, OnFoldoutStateChange))
                    {
                        using (new GUI.Indent(12))
                            HandleConstraintRowsGUI(constraintRowParser.TranslationalRows, memberWrappers, skin);
                    }
                }

                if (constraintRowParser.HasRotationalRows)
                {
                    GUI.Separator();

                    if (GUI.Foldout(Selected(SelectedFoldout.OrdinaryElementaryRotational), GUI.MakeLabel("Rotational properties </b>(about constraint axis)<b>", true), skin, OnFoldoutStateChange))
                    {
                        using (new GUI.Indent(12))
                            HandleConstraintRowsGUI(constraintRowParser.RotationalRows, memberWrappers, skin);
                    }
                }

                ElementaryConstraintController[] controllers = Constraint.GetElementaryConstraintControllers();
                if (controllers.Length > 0)
                {
                    if (!constraintRowParser.Empty)
                    {
                        GUI.Separator();
                    }

                    if (GUI.Foldout(Selected(SelectedFoldout.Controllers), GUI.MakeLabel("Controllers", true), skin, OnFoldoutStateChange))
                    {
                        using (new GUI.Indent(12)) {
                            GUI.Separator();
                            foreach (var controller in controllers)
                            {
                                HandleConstraintControllerGUI(controller, skin);

                                GUI.Separator();
                            }
                        }
                    }
                }
            }
            catch (AgXUnity.Exception e) {
                GUILayout.Label(GUI.MakeLabel("Unable to parse constraint rows", true), skin.label);
                GUILayout.Label(GUI.MakeLabel("  - " + e.Message, Color.red), skin.label);
            }
        }
Exemple #8
0
        private void OnPropertyGUI(CableProperties.Direction dir, CableProperties properties, GUISkin skin)
        {
            var data = EditorData.Instance.GetData(properties, "CableProperty" + dir.ToString());

            if (GUI.Foldout(data, GUI.MakeLabel(dir.ToString()), skin))
            {
                using (new GUI.Indent(12)) {
                    GUI.Separator();

                    properties[dir].YoungsModulus = Mathf.Clamp(EditorGUILayout.FloatField(GUI.MakeLabel("Young's modulus"), properties[dir].YoungsModulus), 1.0E-6f, float.PositiveInfinity);
                    properties[dir].YieldPoint    = Mathf.Clamp(EditorGUILayout.FloatField(GUI.MakeLabel("Yield point"), properties[dir].YieldPoint), 0.0f, float.PositiveInfinity);
                    properties[dir].Damping       = Mathf.Clamp(EditorGUILayout.FloatField(GUI.MakeLabel("Spook damping"), properties[dir].Damping), 0.0f, float.PositiveInfinity);
                }
            }
        }
Exemple #9
0
        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);
                    }
                }
            }
        }
Exemple #10
0
        public override void OnPreTargetMembersGUI(GUISkin skin)
        {
            bool guiWasEnabled = UnityEngine.GUI.enabled;

            bool toggleSelectParent   = false;
            bool toggleFindGivenPoint = false;
            bool toggleSelectEdge     = false;
            bool togglePositionHandle = false;

            GUILayout.BeginHorizontal();
            {
                UnityEngine.GUI.enabled = true;
                GUI.ToolsLabel(skin);

                using (GUI.ToolButtonData.ColorBlock) {
                    toggleSelectParent = GUI.ToolButton(GUI.Symbols.SelectInSceneViewTool, SelectParent, "Select parent object by selecting object in scene view", skin);

                    UnityEngine.GUI.enabled = guiWasEnabled;

                    toggleFindGivenPoint = GUI.ToolButton(GUI.Symbols.SelectPointTool, FindTransformGivenPointOnSurface, "Find position and rotation given point and direction on an objects surface", skin);
                    toggleSelectEdge     = GUI.ToolButton(GUI.Symbols.SelectEdgeTool, FindTransformGivenEdge, "Find position and rotation given a triangle or principal edge", skin);
                    togglePositionHandle = GUI.ToolButton(GUI.Symbols.PositionHandleTool, TransformHandleActive, "Position/rotation handle", skin);
                }
            }
            GUILayout.EndHorizontal();

            if (toggleSelectParent)
            {
                SelectParent = !SelectParent;
            }
            if (toggleFindGivenPoint)
            {
                FindTransformGivenPointOnSurface = !FindTransformGivenPointOnSurface;
            }
            if (toggleSelectEdge)
            {
                FindTransformGivenEdge = !FindTransformGivenEdge;
            }
            if (togglePositionHandle)
            {
                TransformHandleActive = !TransformHandleActive;
            }

            GUI.Separator();
        }
Exemple #11
0
        public void OnInspectorGUI(GUISkin skin)
        {
            if (RigidBody == null || GetChildren().Length == 0)
            {
                PerformRemoveFromParent();
                return;
            }

            GUILayout.Space(4);
            using (GUI.AlignBlock.Center)
                GUILayout.Label(GUI.MakeLabel("Create visual tool", 16, true), skin.label);

            GUILayout.Space(2);
            GUI.Separator();
            GUILayout.Space(4);

            foreach (var tool in GetChildren <ShapeVisualCreateTool>())
            {
                if (ShapeVisual.HasShapeVisual(tool.Shape))
                {
                    continue;
                }

                using (GUI.AlignBlock.Center)
                    GUILayout.Label(GUI.MakeLabel(tool.Shape.name, 16, true), skin.label);
                tool.OnInspectorGUI(skin, true);
            }

            var createCancelState = GUI.CreateCancelButtons(true, skin, "Create shape visual for shapes that hasn't already got one.");

            if (createCancelState == GUI.CreateCancelState.Create)
            {
                foreach (var tool in GetChildren <ShapeVisualCreateTool>())
                {
                    if (!ShapeVisual.HasShapeVisual(tool.Shape))
                    {
                        tool.CreateShapeVisual();
                    }
                }
            }
            if (createCancelState != GUI.CreateCancelState.Nothing)
            {
                PerformRemoveFromParent();
            }
        }
Exemple #12
0
        protected override bool OverrideOnInspectorGUI(EditorData target, GUISkin skin)
        {
            using (GUI.AlignBlock.Center)
                GUILayout.Label(GUI.MakeLabel("Editor data", 18, true), skin.label);

            GUI.Separator3D();

            const float firstLabelWidth = 190;

            GUILayout.BeginHorizontal();
            {
                TimeSpan span = TimeSpan.FromSeconds(target.SecondsSinceLastGC);
                GUILayout.Label(GUI.MakeLabel("Seconds since last GC:"), skin.label, GUILayout.Width(firstLabelWidth));
                GUILayout.Label(GUI.MakeLabel(string.Format("{0:D2}m:{1:D2}s", span.Minutes, span.Seconds), true), skin.label);
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            {
                GUILayout.Label(GUI.MakeLabel("Number of data entries:"), skin.label, GUILayout.Width(firstLabelWidth));
                GUILayout.Label(GUI.MakeLabel(target.NumEntries.ToString(), true), skin.label);
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            {
                GUILayout.Label(GUI.MakeLabel("Number of cached data entries:"), skin.label, GUILayout.Width(firstLabelWidth));
                GUILayout.Label(GUI.MakeLabel(target.NumCachedEntries.ToString(), true), skin.label);
            }
            GUILayout.EndHorizontal();

            GUI.Separator();
            using (new GUI.ColorBlock(Color.Lerp(UnityEngine.GUI.color, Color.green, 0.25f)))
                using (GUI.AlignBlock.Center) {
                    if (GUILayout.Button(GUI.MakeLabel("Collect garbage"), skin.button, GUILayout.Width(110)))
                    {
                        target.GC();
                    }
                }
            GUI.Separator();

            EditorUtility.SetDirty(target);

            return(true);
        }
Exemple #13
0
        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();
        }
Exemple #14
0
        public void OnInspectorGUI(GUISkin skin, bool onlyNameAndMaterial = false)
        {
            if (!onlyNameAndMaterial)
            {
                GUILayout.Space(4);
                using (GUI.AlignBlock.Center)
                    GUILayout.Label(GUI.MakeLabel("Create visual tool", 16, true), skin.label);

                GUILayout.Space(2);
                GUI.Separator();
                GUILayout.Space(4);
            }

            GUILayout.BeginHorizontal();
            {
                GUILayout.Label(GUI.MakeLabel("Name:", true), skin.label, GUILayout.Width(64));
                Name = GUILayout.TextField(Name, skin.textField, GUILayout.ExpandWidth(true));
            }
            GUILayout.EndHorizontal();

            GUI.MaterialEditor(GUI.MakeLabel("Material:", true),
                               64,
                               Material,
                               skin,
                               newMaterial => Material = newMaterial);

            GUI.Separator();

            if (!onlyNameAndMaterial)
            {
                var createCancelState = GUI.CreateCancelButtons(Preview != null, skin, "Create new shape visual");
                if (createCancelState == GUI.CreateCancelState.Create)
                {
                    CreateShapeVisual();
                }
                if (createCancelState != GUI.CreateCancelState.Nothing)
                {
                    PerformRemoveFromParent();
                    return;
                }
            }
        }
Exemple #15
0
        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);
        }
        public override void OnPreTargetMembersGUI(GUISkin skin)
        {
            GUILayout.Label(GUI.MakeLabel("Debug render manager", 16, true), GUI.Align(skin.label, TextAnchor.MiddleCenter));

            GUI.Separator();

            Manager.RenderShapes = GUI.Toggle(GUI.MakeLabel("Debug render shapes"), Manager.RenderShapes, skin.button, skin.label);
            GUI.MaterialEditor(GUI.MakeLabel("Shape material"), 100, Manager.ShapeRenderMaterial, skin, newMaterial => Manager.ShapeRenderMaterial = newMaterial, true);

            GUI.Separator();

            using (new GUILayout.HorizontalScope()) {
                Manager.RenderContacts = GUI.Toggle(GUI.MakeLabel("Render contacts"), Manager.RenderContacts, skin.button, skin.label);
                Manager.ContactColor   = EditorGUILayout.ColorField(Manager.ContactColor);
            }

            Manager.ContactScale = EditorGUILayout.Slider(GUI.MakeLabel("Scale"), Manager.ContactScale, 0.0f, 1.0f);

            GUI.Separator();

            Manager.ColorizeBodies = GUI.Toggle(GUI.MakeLabel("Colorize bodies",
                                                              false,
                                                              "Every rigid body instance will be rendered with a unique color (wire framed)."),
                                                Manager.ColorizeBodies,
                                                skin.button,
                                                skin.label);
            Manager.HighlightMouseOverObject = GUI.Toggle(GUI.MakeLabel("Highlight mouse over object",
                                                                        false,
                                                                        "Highlight mouse over object in scene view."),
                                                          Manager.HighlightMouseOverObject,
                                                          skin.button,
                                                          skin.label);
            Manager.IncludeInBuild = GUI.Toggle(GUI.MakeLabel("Include in build",
                                                              false,
                                                              "Include debug rendering when building the project."),
                                                Manager.IncludeInBuild,
                                                skin.button,
                                                skin.label);
        }
Exemple #17
0
        public override void OnPostTargetMembersGUI(GUISkin skin)
        {
            if (Wire.BeginWinch != null)
            {
                GUI.Separator();
                GUILayout.Label(GUI.MakeLabel("Begin winch", true), skin.label);
                using (new GUI.Indent(12))
                    BaseEditor <Wire> .Update(Wire.BeginWinch, Wire, skin);
                GUI.Separator();
            }
            if (Wire.EndWinch != null)
            {
                if (Wire.BeginWinch == null)
                {
                    GUI.Separator();
                }

                GUILayout.Label(GUI.MakeLabel("End winch", true), skin.label);
                using (new GUI.Indent(12))
                    BaseEditor <Wire> .Update(Wire.EndWinch, Wire, skin);
                GUI.Separator();
            }
        }
Exemple #18
0
        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);
                    }
                }
            }
        }
Exemple #19
0
        public override void OnPreTargetMembersGUI(GUISkin skin)
        {
            bool toggleFindTransformGivenPoint = false;
            bool toggleFindTransformGivenEdge  = false;
            bool toggleShapeCreate             = false;
            bool toggleConstraintCreate        = false;
            bool toggleDisableCollisions       = false;
            bool toggleRigidBodyVisualCreate   = false;

            GUILayout.BeginHorizontal();
            {
                GUI.ToolsLabel(skin);
                using (GUI.ToolButtonData.ColorBlock) {
                    toggleFindTransformGivenPoint = GUI.ToolButton(GUI.Symbols.SelectPointTool, FindTransformGivenPointTool, "Find rigid body transform given point on object.", skin);
                    toggleFindTransformGivenEdge  = GUI.ToolButton(GUI.Symbols.SelectEdgeTool, FindTransformGivenEdgeTool, "Find rigid body transform given edge on object.", skin);
                    toggleShapeCreate             = GUI.ToolButton(GUI.Symbols.ShapeCreateTool, ShapeCreateTool, "Create shape from visual objects", skin);
                    toggleConstraintCreate        = GUI.ToolButton(GUI.Symbols.ConstraintCreateTool, ConstraintCreateTool, "Create constraint to this rigid body", skin);
                    toggleDisableCollisions       = GUI.ToolButton(GUI.Symbols.DisableCollisionsTool, DisableCollisionsTool, "Disable collisions against other objects", skin);
                    bool createShapeVisualValid = Tools.RigidBodyVisualCreateTool.ValidForNewShapeVisuals(RigidBody);
                    using (new EditorGUI.DisabledGroupScope(!createShapeVisualValid))
                        toggleRigidBodyVisualCreate = GUI.ToolButton(GUI.Symbols.ShapeVisualCreateTool,
                                                                     RigidBodyVisualCreateTool,
                                                                     "Create visual representation of each physical shape in this body",
                                                                     skin,
                                                                     14);
                }
            }
            GUILayout.EndHorizontal();

            if (ShapeCreateTool)
            {
                GUI.Separator();

                GetChild <ShapeCreateTool>().OnInspectorGUI(skin);
            }
            if (ConstraintCreateTool)
            {
                GUI.Separator();

                GetChild <ConstraintCreateTool>().OnInspectorGUI(skin);
            }
            if (DisableCollisionsTool)
            {
                GUI.Separator();

                GetChild <DisableCollisionsTool>().OnInspectorGUI(skin);
            }
            if (RigidBodyVisualCreateTool)
            {
                GUI.Separator();

                GetChild <RigidBodyVisualCreateTool>().OnInspectorGUI(skin);
            }

            GUI.Separator();

            GUILayout.Label(GUI.MakeLabel("Mass properties", true), skin.label);
            using (new GUI.Indent(12))
                BaseEditor <MassProperties> .Update(RigidBody.MassProperties, RigidBody.MassProperties, skin);
            GUI.Separator();

            if (toggleFindTransformGivenPoint)
            {
                FindTransformGivenPointTool = !FindTransformGivenPointTool;
            }
            if (toggleFindTransformGivenEdge)
            {
                FindTransformGivenEdgeTool = !FindTransformGivenEdgeTool;
            }
            if (toggleShapeCreate)
            {
                ShapeCreateTool = !ShapeCreateTool;
            }
            if (toggleConstraintCreate)
            {
                ConstraintCreateTool = !ConstraintCreateTool;
            }
            if (toggleDisableCollisions)
            {
                DisableCollisionsTool = !DisableCollisionsTool;
            }
            if (toggleRigidBodyVisualCreate)
            {
                RigidBodyVisualCreateTool = !RigidBodyVisualCreateTool;
            }
        }
        public override void OnPreTargetMembersGUI(GUISkin skin)
        {
            var  disabledPairs = Manager.DisabledPairs;
            bool clearPressed  = false;
            bool addPressed    = false;
            CollisionGroupEntryPair erasePair = null;

            GUILayout.Label(GUI.MakeLabel("Collision Groups Manager", 18, true), new GUIStyle(skin.label)
            {
                alignment = TextAnchor.MiddleCenter
            });

            GUI.Separator3D();

            GUILayout.Label(GUI.MakeLabel("Add pair", true), new GUIStyle(skin.label)
            {
                alignment = TextAnchor.MiddleCenter
            });

            GUILayout.BeginVertical(skin.textArea);
            {
                HandleCollisionGroupEntryPair(m_groupEntryPairToAdd, skin);

                GUILayout.BeginHorizontal();
                {
                    GUILayout.FlexibleSpace();

                    UnityEngine.GUI.enabled = m_groupEntryPairToAdd.First.Tag.Length > 0 || m_groupEntryPairToAdd.Second.Tag.Length > 0;
                    GUILayout.BeginVertical();
                    {
                        GUILayout.Space(8);
                        using (new GUI.ColorBlock(Color.Lerp(UnityEngine.GUI.color, Color.red, 0.1f)))
                            clearPressed = GUILayout.Button(GUI.MakeLabel("Clear"), skin.button, GUILayout.Width(64), GUILayout.Height(16));
                    }
                    GUILayout.EndVertical();

                    UnityEngine.GUI.enabled = m_groupEntryPairToAdd.First.Tag.Length > 0 && m_groupEntryPairToAdd.Second.Tag.Length > 0;
                    using (new GUI.ColorBlock(Color.Lerp(UnityEngine.GUI.color, Color.green, 0.1f)))
                        addPressed = GUILayout.Button(GUI.MakeLabel("Add", false, "Add pair to disabled pairs."), skin.button, GUILayout.Width(64), GUILayout.Height(22));

                    UnityEngine.GUI.enabled = true;
                }
                GUILayout.EndHorizontal();
            }
            GUILayout.EndVertical();

            GUI.Separator3D();

            if (GUI.Foldout(FoldoutDataEntry, GUI.MakeLabel("Disabled Pairs [" + disabledPairs.Length + "]"), skin))
            {
                using (new GUI.Indent(12)) {
                    foreach (var disabledPair in disabledPairs)
                    {
                        GUILayout.BeginHorizontal();
                        {
                            GUI.Separator(1, 10);
                            using (new GUI.ColorBlock(Color.Lerp(UnityEngine.GUI.color, Color.red, 0.1f)))
                                if (GUILayout.Button(GUI.MakeLabel(GUI.Symbols.ListEraseElement.ToString()), skin.button, GUILayout.Width(18), GUILayout.Height(14)))
                                {
                                    erasePair = disabledPair;
                                }
                        }
                        GUILayout.EndHorizontal();

                        HandleCollisionGroupEntryPair(disabledPair, skin);
                    }
                }
            }

            GUI.Separator3D();

            if (clearPressed)
            {
                m_groupEntryPairToAdd.First.Tag = m_groupEntryPairToAdd.Second.Tag = string.Empty;
            }
            if (addPressed)
            {
                Manager.SetEnablePair(m_groupEntryPairToAdd.First.Tag, m_groupEntryPairToAdd.Second.Tag, false);
                m_groupEntryPairToAdd.First.Tag = m_groupEntryPairToAdd.Second.Tag = string.Empty;
                FoldoutDataEntry.Bool           = true;
            }
            if (erasePair != null)
            {
                if (EditorUtility.DisplayDialog("Remove pair", "Erase disabled pair: " + erasePair.First.Tag + " and " + erasePair.Second.Tag + "?", "Yes", "No"))
                {
                    Manager.SetEnablePair(erasePair.First.Tag, erasePair.Second.Tag, true);
                }
            }
        }
        public void OnInspectorGUI(GUISkin skin)
        {
            using (GUI.AlignBlock.Center)
                GUILayout.Label(GUI.MakeLabel("AgXUnity Editor Settings", 24, true), skin.label);

            GUI.Separator3D();

            // BuiltInToolsTool settings GUI.
            {
                using (GUI.AlignBlock.Center)
                    GUILayout.Label(GUI.MakeLabel("Built in tools", 16, true), skin.label);

                //GUI.Separator();

                HandleKeyHandlerGUI(GUI.MakeLabel("Select game object"), BuiltInToolsTool_SelectGameObjectKeyHandler, skin);
                HandleKeyHandlerGUI(GUI.MakeLabel("Select rigid body game object"), BuiltInToolsTool_SelectRigidBodyKeyHandler, skin);
                HandleKeyHandlerGUI(GUI.MakeLabel("Pick handler (scene view)"), BuiltInToolsTool_PickHandlerKeyHandler, skin);

                GUI.Separator();
            }

            // Developer settings.
            {
                using (GUI.AlignBlock.Center)
                    GUILayout.Label(GUI.MakeLabel("AGXUnity Developer", 16, true), skin.label);

                AutoFetchAGXUnityDlls = GUI.Toggle(GUI.MakeLabel("Auto fetch AGXUnity/AGXUnityEditor"),
                                                   AutoFetchAGXUnityDlls,
                                                   skin.button,
                                                   GUI.Align(skin.label, TextAnchor.MiddleLeft),
                                                   new GUILayoutOption[]
                {
                    GUILayout.Width(ToggleButtonSize),
                    GUILayout.Height(ToggleButtonSize)
                },
                                                   new GUILayoutOption[]
                {
                    GUILayout.Height(ToggleButtonSize)
                });

                using (new EditorGUI.DisabledScope(!AutoFetchAGXUnityDlls)) {
                    using (new GUILayout.HorizontalScope()) {
                        GUILayout.Space(ToggleButtonSize + 4);
                        GUILayout.Label(GUI.MakeLabel("Checkout directory"), skin.label, GUILayout.Width(160));
                        var statusColor = AGXUnityCheckoutDirValid ?
                                          Color.Lerp(Color.white, Color.green, 0.2f) :
                                          Color.Lerp(Color.white, Color.red, 0.2f);
                        var textFieldStyle = new GUIStyle(skin.textField);
                        var prevColor      = UnityEngine.GUI.backgroundColor;
                        UnityEngine.GUI.backgroundColor = statusColor;
                        AGXUnityCheckoutDir             = GUILayout.TextField(AGXUnityCheckoutDir, skin.textField);
                        UnityEngine.GUI.backgroundColor = prevColor;
                        if (GUILayout.Button(GUI.MakeLabel("...", false, "Open file panel"),
                                             skin.button,
                                             GUILayout.Width(28)))
                        {
                            AGXUnityCheckoutDir = EditorUtility.OpenFolderPanel("AGXUnity checkout directory", AGXUnityCheckoutDir, "");
                        }
                    }
                }

                GUI.Separator();
            }

            GUI.Separator3D();
        }
        private void RouteGUI(GUISkin skin)
        {
            GUIStyle invalidNodeStyle = new GUIStyle(skin.label);

            invalidNodeStyle.normal.background = GUI.CreateColoredTexture(4, 4, Color.Lerp(UnityEngine.GUI.color, Color.red, 0.75f));

            bool  addNewPressed       = false;
            bool  insertBeforePressed = false;
            bool  insertAfterPressed  = false;
            bool  erasePressed        = false;
            NodeT listOpNode          = null;

            Undo.RecordObject(Route, "Route changed");

            GUI.Separator();

            if (GUI.Foldout(EditorData.Instance.GetData(Parent, "Route", (entry) => { entry.Bool = true; }), GUI.MakeLabel("Route", true), skin))
            {
                GUI.Separator();

                Route <NodeT> .ValidatedRoute validatedRoute = Route.GetValidated();
                foreach (var validatedNode in validatedRoute)
                {
                    var node = validatedNode.Node;
                    using (new GUI.Indent(12)) {
                        if (validatedNode.Valid)
                        {
                            GUILayout.BeginVertical();
                        }
                        else
                        {
                            GUILayout.BeginVertical(invalidNodeStyle);
                        }

                        if (GUI.Foldout(GetFoldoutData(node),
                                        GUI.MakeLabel(GetNodeTypeString(node) + " | " + SelectGameObjectDropdownMenuTool.GetGUIContent(node.Parent).text,
                                                      !validatedNode.Valid,
                                                      validatedNode.ErrorString),
                                        skin,
                                        (newState) =>
                        {
                            Selected = newState ? node : null;
                            EditorUtility.SetDirty(Parent);
                        }))
                        {
                            OnPreFrameGUI(node, skin);

                            GUI.HandleFrame(node, skin, 12);

                            OnPostFrameGUI(node, skin);

                            GUILayout.BeginHorizontal();
                            {
                                GUILayout.FlexibleSpace();

                                using (new GUI.ColorBlock(Color.Lerp(UnityEngine.GUI.color, Color.green, 0.1f))) {
                                    insertBeforePressed = GUILayout.Button(GUI.MakeLabel(GUI.Symbols.ListInsertElementBefore.ToString(),
                                                                                         16,
                                                                                         false,
                                                                                         "Insert a new node before this node"),
                                                                           skin.button,
                                                                           GUILayout.Width(20),
                                                                           GUILayout.Height(16)) || insertBeforePressed;
                                    insertAfterPressed = GUILayout.Button(GUI.MakeLabel(GUI.Symbols.ListInsertElementAfter.ToString(),
                                                                                        16,
                                                                                        false,
                                                                                        "Insert a new node after this node"),
                                                                          skin.button,
                                                                          GUILayout.Width(20),
                                                                          GUILayout.Height(16)) || insertAfterPressed;
                                }
                                using (new GUI.ColorBlock(Color.Lerp(UnityEngine.GUI.color, Color.red, 0.1f)))
                                    erasePressed = GUILayout.Button(GUI.MakeLabel(GUI.Symbols.ListEraseElement.ToString(),
                                                                                  16,
                                                                                  false,
                                                                                  "Erase this node"),
                                                                    skin.button,
                                                                    GUILayout.Width(20),
                                                                    GUILayout.Height(16)) || erasePressed;

                                if (listOpNode == null && (insertBeforePressed || insertAfterPressed || erasePressed))
                                {
                                    listOpNode = node;
                                }
                            }
                            GUILayout.EndHorizontal();
                        }

                        GUILayout.EndVertical();

                        GUI.Separator();
                    }

                    if (GUILayoutUtility.GetLastRect().Contains(Event.current.mousePosition) &&
                        Event.current.type == EventType.MouseDown &&
                        Event.current.button == 0)
                    {
                        Selected = node;
                    }
                }

                GUILayout.BeginHorizontal();
                {
                    GUILayout.FlexibleSpace();

                    using (new GUI.ColorBlock(Color.Lerp(UnityEngine.GUI.color, Color.green, 0.1f)))
                        addNewPressed = GUILayout.Button(GUI.MakeLabel(GUI.Symbols.ListInsertElementAfter.ToString(),
                                                                       16,
                                                                       false,
                                                                       "Add new node to route"),
                                                         skin.button,
                                                         GUILayout.Width(20),
                                                         GUILayout.Height(16));
                    if (listOpNode == null && addNewPressed)
                    {
                        listOpNode = Route.LastOrDefault();
                    }
                }
                GUILayout.EndHorizontal();
            }

            GUI.Separator();

            if (addNewPressed || insertBeforePressed || insertAfterPressed)
            {
                NodeT newRouteNode = null;
                // Clicking "Add" will not copy data from last node.
                newRouteNode = listOpNode != null?
                               addNewPressed?
                               RouteNode.Create <NodeT>(null, listOpNode.Position, listOpNode.Rotation) :
                                   RouteNode.Create <NodeT>(listOpNode.Parent, listOpNode.LocalPosition, listOpNode.LocalRotation) :
                                       RouteNode.Create <NodeT>();

                OnNodeCreate(newRouteNode, listOpNode, addNewPressed);

                if (addNewPressed)
                {
                    Route.Add(newRouteNode);
                }
                if (insertBeforePressed)
                {
                    Route.InsertBefore(newRouteNode, listOpNode);
                }
                if (insertAfterPressed)
                {
                    Route.InsertAfter(newRouteNode, listOpNode);
                }

                if (newRouteNode != null)
                {
                    CreateRouteNodeTool(newRouteNode);
                    Selected = newRouteNode;
                }
            }
            else if (listOpNode != null && erasePressed)
            {
                Selected = null;
                Route.Remove(listOpNode);
            }
        }
Exemple #23
0
        public override void OnPostTargetMembersGUI(GUISkin skin)
        {
            GUI.Separator();
            using (new GUILayout.HorizontalScope()) {
                EditorGUI.BeginDisabledGroup(!Application.isPlaying);
                if (GUILayout.Button(GUI.MakeLabel("Save current step as (.agx)...",
                                                   false,
                                                   "Save scene in native file format when the editor is in play mode."), skin.button))
                {
                    string result = EditorUtility.SaveFilePanel("Save scene as .agx", "Assets", UnityEditor.SceneManagement.EditorSceneManager.GetActiveScene().name, "agx");
                    if (result != string.Empty)
                    {
                        var success = Simulation.SaveToNativeFile(result);
                        if (success)
                        {
                            Debug.Log("Successfully wrote simulation to file: " + result);
                        }
                    }
                }

                if (GUILayout.Button(GUI.MakeLabel("Open in AGX native viewer",
                                                   false,
                                                   "Creates Lua file, saves current scene to an .agx file and executes luaagx.exe."), skin.button))
                {
                    Simulation.OpenInAgXViewer();
                }
                EditorGUI.EndDisabledGroup();
            }

            GUI.Separator();
            Simulation.SavePreFirstStep = GUI.Toggle(GUI.MakeLabel("Dump initial (.agx):"),
                                                     Simulation.SavePreFirstStep,
                                                     skin.button,
                                                     skin.label);
            EditorGUI.BeginDisabledGroup(!Simulation.SavePreFirstStep);
            {
                using (new GUILayout.HorizontalScope()) {
                    GUILayout.Space(26);
                    Simulation.SavePreFirstStepPath = GUILayout.TextField(Simulation.SavePreFirstStepPath, skin.textField);
                    if (GUILayout.Button(GUI.MakeLabel("...", false, "Open file panel"),
                                         skin.button,
                                         GUILayout.Width(28)))
                    {
                        string result = EditorUtility.SaveFilePanel("Path to initial dump (including file name and extension)",
                                                                    SaveInitialPath,
                                                                    UnityEditor.SceneManagement.EditorSceneManager.GetActiveScene().name, "agx");
                        if (result != string.Empty)
                        {
                            SaveInitialPath = result;
                            var fileInfo = new System.IO.FileInfo(SaveInitialPath);
                            if (fileInfo.Extension == ".agx" || fileInfo.Extension == ".aagx")
                            {
                                Simulation.SavePreFirstStepPath = SaveInitialPath;
                            }
                            else
                            {
                                Debug.Log("Unknown file extension: " + fileInfo.Extension);
                            }
                        }
                    }
                }
            }
            EditorGUI.EndDisabledGroup();
        }
Exemple #24
0
        private void HandleModeRigidBodyGUI(GUISkin skin)
        {
            GUI.Separator3D();

            using (GUI.AlignBlock.Center) {
                if (m_subMode == SubMode.SelectRigidBody)
                {
                    GUILayout.Label(GUI.MakeLabel("Select rigid body object in scene view.", true), skin.label);
                }
                else
                {
                    GUILayout.Label(GUI.MakeLabel("Select object(s) in scene view.", true), skin.label);
                }
            }

            GUI.Separator();

            bool selectionHasRigidBody         = m_selection.Find(entry => entry.Object.GetComponentInParent <RigidBody>() != null) != null;
            bool createNewRigidBodyPressed     = false;
            bool addToExistingRigidBodyPressed = false;
            bool moveToNewRigidBodyPressed     = false;

            GUILayout.BeginHorizontal();
            {
                GUILayout.Space(12);
                GUILayout.BeginVertical();
                {
                    UnityEngine.GUI.enabled       = m_selection.Count == 0 || !selectionHasRigidBody;
                    createNewRigidBodyPressed     = GUILayout.Button(GUI.MakeLabel("Create new" + (m_selection.Count == 0 ? " (empty)" : ""), false, "Create new rigid body with selected objects"), skin.button, GUILayout.Width(128));
                    UnityEngine.GUI.enabled       = m_selection.Count > 0 && Assembly.GetComponentInChildren <RigidBody>() != null;
                    addToExistingRigidBodyPressed = GUILayout.Button(GUI.MakeLabel("Add to existing", false, "Add selected objects to existing rigid body"), GUI.ConditionalCreateSelectedStyle(m_subMode == SubMode.SelectRigidBody, skin.button), GUILayout.Width(100));
                    UnityEngine.GUI.enabled       = selectionHasRigidBody;
                    moveToNewRigidBodyPressed     = GUILayout.Button(GUI.MakeLabel("Move to new", false, "Move objects that already contains a rigid body to a new rigid body"), skin.button, GUILayout.Width(85));
                    UnityEngine.GUI.enabled       = true;
                }
                GUILayout.EndVertical();
            }
            GUILayout.EndHorizontal();

            GUI.Separator3D();

            // Creates new rigid body and move selected objects to it (as children).
            if (createNewRigidBodyPressed || moveToNewRigidBodyPressed)
            {
                CreateOrMoveToRigidBodyFromSelectionEntries(m_selection);
                m_selection.Clear();
            }
            // Toggle to select a rigid body in scene view to move the current selection to.
            else if (addToExistingRigidBodyPressed)
            {
                // This will toggle if sub-mode already is SelectRigidBody.
                ChangeSubMode(SubMode.SelectRigidBody);
            }

            // The user has chosen a rigid body to move the current selection to.
            if (m_rbSelection != null)
            {
                CreateOrMoveToRigidBodyFromSelectionEntries(m_selection, m_rbSelection.RigidBody.gameObject);
                m_selection.Clear();
                ChangeSubMode(SubMode.None);
            }
        }
Exemple #25
0
        public override void OnPostTargetMembersGUI(GUISkin skin)
        {
            var shapeVisual = ShapeVisual.Find(Shape);

            if (shapeVisual == null)
            {
                return;
            }

            GUI.Separator();
            if (!GUI.FoldoutEx(EditorData.Instance.GetData(Shape,
                                                           "Visual",
                                                           entry => entry.Bool = true),
                               skin.button,
                               GUI.MakeLabel("Shape Visual", 12, true),
                               new GUIStyle(skin.label)
            {
                alignment = TextAnchor.UpperCenter
            }))
            {
                return;
            }

            GUI.Separator();

            GUILayout.Space(6);

            Undo.RecordObjects(shapeVisual.GetComponentsInChildren <MeshRenderer>(), "Shape visual material");

            var materials = shapeVisual.GetMaterials();

            if (materials.Length > 1)
            {
                var distinctMaterials = materials.Distinct().ToArray();
                using (GUI.AlignBlock.Center) {
                    GUILayout.Label(GUI.MakeLabel("Displays material if all materials are the same <b>(otherwise None)</b> and/or assign new material to all objects in this shape."),
                                    new GUIStyle(skin.textArea)
                    {
                        alignment = TextAnchor.MiddleCenter
                    }, GUILayout.Width(Screen.width - 60));
                }
                GUI.MaterialEditor(GUI.MakeLabel("Common material:", true),
                                   128,
                                   distinctMaterials.Length == 1 ? distinctMaterials.First() : null,
                                   skin,
                                   newMaterial => shapeVisual.SetMaterial(newMaterial));

                GUILayout.Space(6);

                GUI.Separator();

                using (GUI.AlignBlock.Center)
                    GUILayout.Label(GUI.MakeLabel("Material list", true), skin.label);

                GUI.Separator();
            }

            for (int i = 0; i < materials.Length; ++i)
            {
                var material           = materials[i];
                var showMaterialEditor = materials.Length == 1 ||
                                         GUI.Foldout(EditorData.Instance.GetData(Shape,
                                                                                 "VisualMaterial" + i),
                                                     GUI.MakeLabel(material.name), skin);
                if (showMaterialEditor)
                {
                    GUI.MaterialEditor(GUI.MakeLabel("Material:", true),
                                       64,
                                       material,
                                       skin,
                                       newMaterial => shapeVisual.ReplaceMaterial(i, newMaterial));
                }
                GUI.Separator();
            }
        }
Exemple #26
0
        public override void OnPreTargetMembersGUI(GUISkin skin)
        {
            bool toggleShapeResizeTool   = false;
            bool toggleShapeCreate       = false;
            bool toggleDisableCollisions = false;
            bool toggleShapeVisualCreate = true;

            GUILayout.BeginHorizontal();
            {
                GUI.ToolsLabel(skin);

                using (GUI.ToolButtonData.ColorBlock) {
                    using (new EditorGUI.DisabledGroupScope(!Tools.ShapeResizeTool.SupportsShape(Shape)))
                        toggleShapeResizeTool = GUI.ToolButton(GUI.Symbols.ShapeResizeTool,
                                                               ShapeResizeTool,
                                                               "Shape resize tool",
                                                               skin,
                                                               24);

                    toggleShapeCreate = GUI.ToolButton(GUI.Symbols.ShapeCreateTool,
                                                       ShapeCreateTool,
                                                       "Create shape from visual objects",
                                                       skin);
                    toggleDisableCollisions = GUI.ToolButton(GUI.Symbols.DisableCollisionsTool,
                                                             DisableCollisionsTool,
                                                             "Disable collisions against other objects",
                                                             skin);

                    using (new EditorGUI.DisabledGroupScope(!Tools.ShapeVisualCreateTool.CanCreateVisual(Shape)))
                        toggleShapeVisualCreate = GUI.ToolButton(GUI.Symbols.ShapeVisualCreateTool,
                                                                 ShapeVisualCreateTool,
                                                                 "Create visual representation of the physical shape",
                                                                 skin,
                                                                 14);
                }
            }
            GUILayout.EndHorizontal();

            GUI.Separator();

            if (ShapeCreateTool)
            {
                GetChild <ShapeCreateTool>().OnInspectorGUI(skin);

                GUI.Separator();
            }
            if (DisableCollisionsTool)
            {
                GetChild <DisableCollisionsTool>().OnInspectorGUI(skin);

                GUI.Separator();
            }
            if (ShapeVisualCreateTool)
            {
                GetChild <ShapeVisualCreateTool>().OnInspectorGUI(skin);

                GUI.Separator();
            }

            if (toggleShapeResizeTool)
            {
                ShapeResizeTool = !ShapeResizeTool;
            }
            if (toggleShapeCreate)
            {
                ShapeCreateTool = !ShapeCreateTool;
            }
            if (toggleDisableCollisions)
            {
                DisableCollisionsTool = !DisableCollisionsTool;
            }
            if (toggleShapeVisualCreate)
            {
                ShapeVisualCreateTool = !ShapeVisualCreateTool;
            }
        }
        private void OnContactMaterialsList(GUISkin skin)
        {
            ContactMaterial contactMaterialToAdd    = null;
            ContactMaterial contactMaterialToRemove = null;

            GUILayout.Label(GUI.MakeLabel("Contact Material Manager", 18, true), new GUIStyle(skin.label)
            {
                alignment = TextAnchor.MiddleCenter
            });
            GUILayout.Space(4);
            GUILayout.Label(GUI.MakeLabel("Drag and drop contact materials into the list below to add/enable the contact material in the simulation."),
                            new GUIStyle(skin.textArea)
            {
                alignment = TextAnchor.MiddleCenter
            });
            GUILayout.Space(4);

            GUI.Separator3D();

            GUILayout.BeginVertical();
            {
                if (GUI.Foldout(FoldoutDataEntry, GUI.MakeLabel("Contact Materials [" + Manager.ContactMaterialEntries.Length + "]"), skin))
                {
                    var contactMaterials = Manager.ContactMaterials;
                    using (new GUI.Indent(12)) {
                        foreach (var contactMaterial in contactMaterials)
                        {
                            GUI.Separator();

                            bool foldoutActive = false;

                            GUILayout.BeginHorizontal();
                            {
                                foldoutActive = GUI.Foldout(EditorData.Instance.GetData(Manager, contactMaterial.name), GUI.MakeLabel(contactMaterial.name), skin);
                                using (GUI.NodeListButtonColor)
                                    if (GUILayout.Button(GUI.MakeLabel(GUI.Symbols.ListEraseElement.ToString(), false, "Erase this element"),
                                                         skin.button,
                                                         new GUILayoutOption[] { GUILayout.Width(20), GUILayout.Height(14) }))
                                    {
                                        contactMaterialToRemove = contactMaterial;
                                    }
                            }
                            GUILayout.EndHorizontal();

                            if (foldoutActive)
                            {
                                using (new GUI.Indent(12))
                                    BaseEditor <ContactMaterial> .Update(contactMaterial, contactMaterial, skin);
                            }
                        }
                    }
                }
            }
            GUILayout.EndVertical();

            // Note that GetLastRect is used here and it's expecting the begin/end vertical rect.
            GUI.HandleDragDrop <ContactMaterial>(GUILayoutUtility.GetLastRect(),
                                                 Event.current,
                                                 (contactMaterial) =>
            {
                contactMaterialToAdd = contactMaterial;
            });

            GUI.Separator();

            GUILayout.BeginHorizontal();
            {
                GUILayout.Label(GUI.MakeLabel("Add:"), skin.label);
                contactMaterialToAdd = EditorGUILayout.ObjectField(null, typeof(ContactMaterial), false) as ContactMaterial ?? contactMaterialToAdd;
            }
            GUILayout.EndHorizontal();

            GUI.Separator3D();

            if (contactMaterialToAdd != null)
            {
                Manager.Add(contactMaterialToAdd);
                FoldoutDataEntry.Bool = true;
            }

            if (contactMaterialToRemove != null)
            {
                Manager.Remove(contactMaterialToRemove);
            }
        }