예제 #1
0
        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;
            }
        }
예제 #2
0
        public override void OnPreTargetMembersGUI(GUISkin skin)
        {
            // TODO: Improvements.
            //   - "Copy-paste" shape.
            //       1. Select object with primitive shape(s)
            //       2. Select object to copy the shape(s) to
            //   - Move from-to existing bodies or create a new body.
            //   - Mesh object operations.
            //       * Simplify assembly
            //       * Multi-select to create meshes
            //   - Inspect element (hold 'i').

            if (!AGXUnity.Utils.Math.IsUniform(Assembly.transform.lossyScale, 1.0E-3f))
            {
                Debug.LogWarning("Scale of AGXUnity.Assembly transform isn't uniform. If a child rigid body is moving under this transform the (visual) behavior is undefined.", Assembly);
            }

            bool rbButtonPressed         = false;
            bool shapeButtonPressed      = false;
            bool constraintButtonPressed = false;

            GUI.ToolsLabel(skin);
            GUILayout.BeginHorizontal();
            {
                GUILayout.Space(12);
                using (GUI.ToolButtonData.ColorBlock) {
                    rbButtonPressed         = GUILayout.Button(GUI.MakeLabel("RB", true, "Assembly rigid body tool"), GUI.ConditionalCreateSelectedStyle(m_mode == Mode.RigidBody, skin.button), GUILayout.Width(30f), GUI.ToolButtonData.Height);
                    shapeButtonPressed      = GUILayout.Button(GUI.MakeLabel("Shape", true, "Assembly shape tool"), GUI.ConditionalCreateSelectedStyle(m_mode == Mode.Shape, skin.button), GUILayout.Width(54f), GUI.ToolButtonData.Height);
                    constraintButtonPressed = GUILayout.Button(GUI.MakeLabel("Constraint", true, "Assembly constraint tool"), GUI.ConditionalCreateSelectedStyle(m_mode == Mode.Constraint, skin.button), GUILayout.Width(80f), GUI.ToolButtonData.Height);
                }
            }
            GUILayout.EndHorizontal();

            HandleModeGUI(skin);

            if (rbButtonPressed)
            {
                ChangeMode(Mode.RigidBody);
            }
            if (shapeButtonPressed)
            {
                ChangeMode(Mode.Shape);
            }
            if (constraintButtonPressed)
            {
                ChangeMode(Mode.Constraint);
            }

            GUI.Separator();

            OnObjectListsGUI(Assembly, skin);
        }
예제 #3
0
        public override void OnPreTargetMembersGUI()
        {
            if (IsMultiSelect)
            {
                if (VisualInSceneView)
                {
                    foreach (var node in Route)
                    {
                        RemoveChild(GetRouteNodeTool(node));
                    }
                    VisualInSceneView = false;
                }
                return;
            }

            bool toggleDisableCollisions = false;
            var  skin = InspectorEditor.Skin;

            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();

                GUI.Separator();
            }

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

            if (toggleDisableCollisions)
            {
                DisableCollisionsTool = !DisableCollisionsTool;
            }
        }
예제 #4
0
        public override void OnPreTargetMembersGUI()
        {
            var  skin          = InspectorEditor.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();
        }
예제 #5
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;

            if (ToolsActive)
            {
                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;
            }
        }
예제 #6
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;
            }
        }
예제 #7
0
        public override void OnPreTargetMembersGUI()
        {
            var skin = InspectorEditor.Skin;

            bool toggleFindTransformGivenPoint = false;
            bool toggleFindTransformGivenEdge  = false;
            bool toggleShapeCreate             = false;
            bool toggleConstraintCreate        = false;
            bool toggleDisableCollisions       = false;
            bool toggleRigidBodyVisualCreate   = false;

            if (!IsMultiSelect && ToolsActive)
            {
                using (new GUILayout.HorizontalScope()) {
                    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);
                        using (new EditorGUI.DisabledGroupScope(!Tools.RigidBodyVisualCreateTool.ValidForNewShapeVisuals(RigidBody)))
                            toggleRigidBodyVisualCreate = GUI.ToolButton(GUI.Symbols.ShapeVisualCreateTool,
                                                                         RigidBodyVisualCreateTool,
                                                                         "Create visual representation of each physical shape in this body",
                                                                         skin,
                                                                         14);
                    }
                }
            }

            if (ShapeCreateTool)
            {
                GUI.Separator();

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

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

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

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

            GUI.Separator();

            GUILayout.Label(GUI.MakeLabel("Mass properties", true), skin.label);
            using (new GUI.Indent(12))
                InspectorEditor.DrawMembersGUI(GetTargets <RigidBody>().Select(rb => rb.MassProperties).ToArray());

            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;
            }
        }