Exemple #1
0
        public override void OnPreTargetMembersGUI()
        {
            bool toggleSelectTireAndRim = false;
            bool toggleSelectTire       = false;
            bool toggleSelectRim        = false;

            if (!EditorApplication.isPlaying && NumTargets == 1)
            {
                InspectorGUI.ToolButtons(InspectorGUI.ToolButtonData.Create(ToolIcon.FindTireRim,
                                                                            SelectTireAndRimToolEnable,
                                                                            "Find Tire, Rim and Tire <-> Rim constraint by selecting Tire in scene view.",
                                                                            () => toggleSelectTireAndRim = true),
                                         InspectorGUI.ToolButtonData.Create(ToolIcon.FindTire,
                                                                            SelectTireToolEnable,
                                                                            "Find Tire by selecting Tire in scene view.",
                                                                            () => toggleSelectTire = true),
                                         InspectorGUI.ToolButtonData.Create(ToolIcon.FindRim,
                                                                            SelectRimToolEnable,
                                                                            "Find Rim by selecting Rim in scene view.",
                                                                            () => toggleSelectRim = true));
            }

            if (toggleSelectTireAndRim)
            {
                SelectTireAndRimToolEnable = !SelectTireAndRimToolEnable;
            }
            if (toggleSelectTire)
            {
                SelectTireToolEnable = !SelectTireToolEnable;
            }
            if (toggleSelectRim)
            {
                SelectRimToolEnable = !SelectRimToolEnable;
            }
        }
Exemple #2
0
        public override void OnPreTargetMembersGUI()
        {
            Track.RemoveInvalidWheels();

            bool toggleSelectWheel       = false;
            bool toggleDisableCollisions = false;

            if (!EditorApplication.isPlaying && NumTargets == 1)
            {
                InspectorGUI.ToolButtons(InspectorGUI.ToolButtonData.Create(ToolIcon.FindTrackWheel,
                                                                            SelectWheelToolEnable,
                                                                            "Select track wheel to add in scene view.",
                                                                            () => toggleSelectWheel = true),
                                         InspectorGUI.ToolButtonData.Create(ToolIcon.DisableCollisions,
                                                                            DisableCollisionsTool,
                                                                            "Disable collisions between this track and other objects.",
                                                                            () => toggleDisableCollisions = true));

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

            if (toggleSelectWheel)
            {
                SelectWheelToolEnable = !SelectWheelToolEnable;
            }
            if (toggleDisableCollisions)
            {
                DisableCollisionsTool = !DisableCollisionsTool;
            }
        }
Exemple #3
0
        public void ToolsGUI(bool isMultiSelect)
        {
            var  skin          = InspectorEditor.Skin;
            bool guiWasEnabled = UnityEngine.GUI.enabled;

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

            UnityEngine.GUI.enabled = !isMultiSelect;
            InspectorGUI.ToolButtons(InspectorGUI.ToolButtonData.Create(ToolIcon.SelectParent,
                                                                        SelectParent,
                                                                        "Select parent object by selecting object in scene view",
                                                                        () => toggleSelectParent = true,
                                                                        !isMultiSelect,
                                                                        () => UnityEngine.GUI.enabled = !isMultiSelect && guiWasEnabled),
                                     InspectorGUI.ToolButtonData.Create(ToolIcon.FindTransformGivenPoint,
                                                                        FindTransformGivenPointOnSurface,
                                                                        "Find position and rotation given point and direction on an objects surface",
                                                                        () => toggleFindGivenPoint = true,
                                                                        !isMultiSelect && guiWasEnabled),
                                     InspectorGUI.ToolButtonData.Create(ToolIcon.FindTransformGivenEdge,
                                                                        FindTransformGivenEdge,
                                                                        "Find position and rotation given a triangle or principal edge",
                                                                        () => toggleSelectEdge = true,
                                                                        !isMultiSelect && guiWasEnabled),
                                     InspectorGUI.ToolButtonData.Create(ToolIcon.TransformHandle,
                                                                        TransformHandleActive,
                                                                        "Position/rotation handle",
                                                                        () => togglePositionHandle = true,
                                                                        !isMultiSelect && guiWasEnabled));

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

            UnityEngine.GUI.enabled = guiWasEnabled;
        }
Exemple #4
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;

            InspectorGUI.ToolButtons(InspectorGUI.ToolButtonData.Create(ToolIcon.DisableCollisions,
                                                                        DisableCollisionsTool,
                                                                        "Disable collisions against other objects",
                                                                        () => toggleDisableCollisions = true));

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

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

            if (toggleDisableCollisions)
            {
                DisableCollisionsTool = !DisableCollisionsTool;
            }
        }
Exemple #5
0
        public override void OnPreTargetMembersGUI()
        {
            var skin = InspectorEditor.Skin;

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

            if (!IsMultiSelect && ToolsActive)
            {
                InspectorGUI.ToolButtons(InspectorGUI.ToolButtonData.Create(ToolIcon.CreateConstraint,
                                                                            ConstraintCreateTool,
                                                                            "Create new constraint to this rigid body.",
                                                                            () => toggleConstraintCreate = true),
                                         InspectorGUI.ToolButtonData.Create(ToolIcon.DisableCollisions,
                                                                            DisableCollisionsTool,
                                                                            "Disable collisions against other objects.",
                                                                            () => toggleDisableCollisions = true),
                                         InspectorGUI.ToolButtonData.Create(ToolIcon.CreateShapeGivenVisual,
                                                                            ShapeCreateTool,
                                                                            "Create shape from child visual object.",
                                                                            () => toggleShapeCreate = true),
                                         InspectorGUI.ToolButtonData.Create(ToolIcon.CreateVisual,
                                                                            RigidBodyVisualCreateTool,
                                                                            "Create visual representation of each physical shape in this body.",
                                                                            () => toggleRigidBodyVisualCreate = true,
                                                                            Tools.RigidBodyVisualCreateTool.ValidForNewShapeVisuals(RigidBody)));
            }

            if (ConstraintCreateTool)
            {
                GetChild <ConstraintCreateTool>().OnInspectorGUI();
            }
            if (DisableCollisionsTool)
            {
                GetChild <DisableCollisionsTool>().OnInspectorGUI();
            }
            if (ShapeCreateTool)
            {
                GetChild <ShapeCreateTool>().OnInspectorGUI();
            }
            if (RigidBodyVisualCreateTool)
            {
                GetChild <RigidBodyVisualCreateTool>().OnInspectorGUI();
            }

            EditorGUILayout.LabelField(GUI.MakeLabel("Mass properties", true), skin.Label);
            using (InspectorGUI.IndentScope.Single)
                InspectorEditor.DrawMembersGUI(GetTargets <RigidBody>().Select(rb => rb.MassProperties).ToArray());

            if (toggleConstraintCreate)
            {
                ConstraintCreateTool = !ConstraintCreateTool;
            }
            if (toggleDisableCollisions)
            {
                DisableCollisionsTool = !DisableCollisionsTool;
            }
            if (toggleShapeCreate)
            {
                ShapeCreateTool = !ShapeCreateTool;
            }
            if (toggleRigidBodyVisualCreate)
            {
                RigidBodyVisualCreateTool = !RigidBodyVisualCreateTool;
            }
        }
Exemple #6
0
        public void OnInspectorGUI()
        {
            if (Mode == ToolMode.Direction)
            {
                StartFrameNameId = "Frame";
            }

            StartFrameToolEnable = Line.Valid;
            EndFrameToolEnable   = Line.Valid;

            bool toggleCreateEdge    = false;
            bool toggleFlipDirection = false;
            bool toggleRenderAsArrow = false;
            bool showTools           = !EditorApplication.isPlaying;

            if (showTools)
            {
                var toolButtonData = new List <InspectorGUI.ToolButtonData>();
                toolButtonData.Add(InspectorGUI.ToolButtonData.Create(ToolIcon.VisualizeLineDirection,
                                                                      RenderAsArrow,
                                                                      "Visualize line direction.",
                                                                      () => toggleRenderAsArrow = true,
                                                                      Mode != ToolMode.Direction));
                toolButtonData.Add(InspectorGUI.ToolButtonData.Create(ToolIcon.FlipDirection,
                                                                      false,
                                                                      "Flip direction.",
                                                                      () => toggleFlipDirection = true,
                                                                      Line.Valid));
                toolButtonData.Add(InspectorGUI.ToolButtonData.Create(ToolIcon.FindTransformGivenEdge,
                                                                      EdgeDetectionToolEnable,
                                                                      "Find line given edge.",
                                                                      () => toggleCreateEdge = true));
                InspectorGUI.ToolButtons(toolButtonData.ToArray());
            }

            if (toggleCreateEdge)
            {
                EdgeDetectionToolEnable = !EdgeDetectionToolEnable;
            }

            if (toggleFlipDirection && EditorUtility.DisplayDialog("Line direction",
                                                                   "Flip direction of " + Name + "?",
                                                                   "Yes",
                                                                   "No"))
            {
                StartFrameToolEnable = false;

                if (Mode == ToolMode.Direction)
                {
                    Line.End.Position   = Line.End.Position - 2.0f * Line.Length * Line.Direction;
                    Line.Start.Rotation = Quaternion.Euler(-Line.Start.Rotation.eulerAngles);
                    Line.End.Rotation   = Quaternion.Euler(-Line.End.Rotation.eulerAngles);
                }
                else
                {
                    var tmp = Line.Start;
                    Line.Start = Line.End;
                    Line.End   = tmp;
                }
            }
            if (toggleRenderAsArrow)
            {
                RenderAsArrow = !RenderAsArrow;
            }

            if (!Line.Valid)
            {
                InspectorGUI.WarningLabel(Name + " isn't created - use Tools to configure.");
            }

            if (StartFrameToolEnable)
            {
                if (InspectorGUI.Foldout(GetToggleData(StartFrameNameId),
                                         GUI.MakeLabel(StartFrameNameId, true)))
                {
                    StartFrameTool.ForceDisableTransformHandle = EditorApplication.isPlaying;
                    using (new GUI.EnabledBlock(!EditorApplication.isPlaying))
                        InspectorGUI.HandleFrame(StartFrameTool.Frame, 1);
                }
            }
            if (EndFrameToolEnable)
            {
                if (InspectorGUI.Foldout(GetToggleData(EndFrameNameId),
                                         GUI.MakeLabel(EndFrameNameId, true)))
                {
                    EndFrameTool.ForceDisableTransformHandle = EditorApplication.isPlaying;
                    using (new GUI.EnabledBlock(!EditorApplication.isPlaying))
                        InspectorGUI.HandleFrame(EndFrameTool.Frame, 1);
                }
            }

            Synchronize();
        }
Exemple #7
0
        public override void OnPreTargetMembersGUI()
        {
            // 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);
            }

            var skin = InspectorEditor.Skin;

            if (!IsMultiSelect)
            {
                bool rbButtonPressed         = false;
                bool shapeButtonPressed      = false;
                bool constraintButtonPressed = false;

                InspectorGUI.ToolButtons(InspectorGUI.ToolButtonData.Create(ToolIcon.CreateRigidBody,
                                                                            m_mode == Mode.RigidBody,
                                                                            "Create/manage rigid bodies in this assembly.",
                                                                            () => rbButtonPressed = true),
                                         InspectorGUI.ToolButtonData.Create(ToolIcon.CreateShapeGivenVisual,
                                                                            m_mode == Mode.Shape,
                                                                            "Create shapes given visual representations.",
                                                                            () => shapeButtonPressed = true),
                                         InspectorGUI.ToolButtonData.Create(ToolIcon.CreateConstraint,
                                                                            m_mode == Mode.Constraint,
                                                                            "Create new constraint.",
                                                                            () => constraintButtonPressed = true));

                HandleModeGUI();

                if (rbButtonPressed)
                {
                    ChangeMode(Mode.RigidBody);
                }
                if (shapeButtonPressed)
                {
                    ChangeMode(Mode.Shape);
                }
                if (constraintButtonPressed)
                {
                    ChangeMode(Mode.Constraint);
                }
            }
            else
            {
                GUILayout.Label(GUI.MakeLabel("Assemblies", 24, true),
                                skin.LabelMiddleCenter);
            }

            OnObjectListsGUI(this);
        }
Exemple #8
0
        public override void OnPreTargetMembersGUI()
        {
            if (IsMultiSelect)
            {
                return;
            }

            var  skin = InspectorEditor.Skin;
            bool toggleShapeResizeTool   = false;
            bool toggleShapeCreate       = false;
            bool toggleDisableCollisions = false;
            bool toggleShapeVisualCreate = false;

            InspectorGUI.ToolButtons(InspectorGUI.ToolButtonData.Create(ToolIcon.ShapeResize,
                                                                        ShapeResizeTool,
                                                                        "Shape resize tool",
                                                                        () => toggleShapeResizeTool = true,
                                                                        Tools.ShapeResizeTool.SupportsShape(Shape)),
                                     InspectorGUI.ToolButtonData.Create(ToolIcon.CreateShapeGivenVisual,
                                                                        ShapeCreateTool,
                                                                        "Create shape from visual objects",
                                                                        () => toggleShapeCreate = true),
                                     InspectorGUI.ToolButtonData.Create(ToolIcon.DisableCollisions,
                                                                        DisableCollisionsTool,
                                                                        "Disable collisions against other objects",
                                                                        () => toggleDisableCollisions = true),
                                     InspectorGUI.ToolButtonData.Create(ToolIcon.CreateVisual,
                                                                        ShapeVisualCreateTool,
                                                                        "Create visual representation of the physical shape",
                                                                        () => toggleShapeVisualCreate = true,
                                                                        Tools.ShapeVisualCreateTool.CanCreateVisual(Shape)));

            if (ShapeCreateTool)
            {
                GetChild <ShapeCreateTool>().OnInspectorGUI();
            }
            if (DisableCollisionsTool)
            {
                GetChild <DisableCollisionsTool>().OnInspectorGUI();
            }
            if (ShapeVisualCreateTool)
            {
                GetChild <ShapeVisualCreateTool>().OnInspectorGUI();
            }

            if (toggleShapeResizeTool)
            {
                ShapeResizeTool = !ShapeResizeTool;
            }
            if (toggleShapeCreate)
            {
                ShapeCreateTool = !ShapeCreateTool;
            }
            if (toggleDisableCollisions)
            {
                DisableCollisionsTool = !DisableCollisionsTool;
            }
            if (toggleShapeVisualCreate)
            {
                ShapeVisualCreateTool = !ShapeVisualCreateTool;
            }
        }