예제 #1
0
        private Tuple <PropertyWrapper, CableProperties.Direction, object> OnPropertyGUI(CableProperties.Direction dir,
                                                                                         CableProperties properties,
                                                                                         GUISkin skin)
        {
            Tuple <PropertyWrapper, CableProperties.Direction, object> changed = null;
            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();

                    var wrappers = PropertyWrapper.FindProperties <CableProperty>(System.Reflection.BindingFlags.Instance |
                                                                                  System.Reflection.BindingFlags.Public);
                    foreach (var wrapper in wrappers)
                    {
                        if (wrapper.GetContainingType() == typeof(float) && InspectorEditor.ShouldBeShownInInspector(wrapper.Member))
                        {
                            var value = EditorGUILayout.FloatField(InspectorGUI.MakeLabel(wrapper.Member),
                                                                   wrapper.Get <float>(properties[dir]));
                            if (UnityEngine.GUI.changed)
                            {
                                changed = new Tuple <PropertyWrapper, CableProperties.Direction, object>(wrapper, dir, value);
                                UnityEngine.GUI.changed = false;
                            }
                        }
                    }
                }
            }
            return(changed);
        }
예제 #2
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();
            }
        }
예제 #3
0
        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);

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

            if (GUILayout.Button(GUI.MakeLabel("Regenerate custom editors"), skin.button))
            {
                Utils.CustomEditorGenerator.Synchronize(true);
            }

            GUI.Separator3D();
        }
예제 #4
0
        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);

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

            BuildPlayer_CopyBinaries = GUI.Toggle(GUI.MakeLabel("<b>Build Player:</b> Copy AGX Dynamics binaries",
                                                                false,
                                                                "[Recommended enabled]\nCopy dependent AGX Dynamics binaries to target player directory."),
                                                  BuildPlayer_CopyBinaries,
                                                  skin.button,
                                                  skin.label);

            GUI.Separator();

            if (GUILayout.Button(GUI.MakeLabel("Regenerate custom editors"), skin.button))
            {
                Utils.CustomEditorGenerator.Synchronize(true);
            }

            GUI.Separator3D();
        }
예제 #5
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;
            }
        }
예제 #6
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);
        }
예제 #7
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);
        }
예제 #8
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();
            }
        }
예제 #9
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);
            }
        }
예제 #10
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);
        }
예제 #11
0
        public override void OnInspectorGUI()
        {
            if (Utils.KeyHandler.HandleDetectKeyOnGUI(this.targets, Event.current))
            {
                return;
            }

            var editorData = this.target as EditorData;
            var skin       = InspectorEditor.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(editorData.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(editorData.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(editorData.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)))
                    {
                        editorData.GC();
                    }
                }
            GUI.Separator();

            EditorUtility.SetDirty(target);
        }
예제 #12
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);
                }
            }
        }
예제 #13
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);
                    }
                }
            }
        }
예제 #14
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;
            }
        }
예제 #15
0
        public override void OnPreTargetMembersGUI()
        {
            var skin = InspectorEditor.Skin;

            GUILayout.Label(GUI.MakeLabel("Debug render manager", 16, true), GUI.Align(skin.label, TextAnchor.MiddleCenter));

            GUI.Separator();

            var newRenderState = GUI.Toggle(GUI.MakeLabel("Debug render shapes"), Manager.RenderShapes, skin.button, skin.label);

            if (newRenderState != Manager.RenderShapes)
            {
                Manager.RenderShapes = newRenderState;
                EditorUtility.SetDirty(Manager);
            }
            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);
        }
예제 #16
0
        public void OnInspectorGUI()
        {
            if (RigidBody == null || GetChildren().Length == 0)
            {
                PerformRemoveFromParent();
                return;
            }

            var skin = InspectorEditor.Skin;

            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(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();
            }
        }
예제 #17
0
        public override void OnPreTargetMembersGUI()
        {
            base.OnPreTargetMembersGUI();

            var sourceObjects = Mesh.SourceObjects;
            var singleSource  = sourceObjects.FirstOrDefault();

            if (IsMultiSelect)
            {
                var undoCollection = new List <Object>();
                foreach (var target in GetTargets <AGXUnity.Collide.Mesh>())
                {
                    if (target != null)
                    {
                        undoCollection.AddRange(target.GetUndoCollection());
                    }
                }
                Undo.RecordObjects(undoCollection.ToArray(), "Mesh source");
            }
            else
            {
                Undo.RecordObjects(Mesh.GetUndoCollection(), "Mesh source");
            }

            var newSingleSource = GUI.ShapeMeshSourceGUI(singleSource, InspectorEditor.Skin);

            if (newSingleSource != null)
            {
                if (IsMultiSelect)
                {
                    foreach (var target in GetTargets <AGXUnity.Collide.Mesh>())
                    {
                        if (target != null)
                        {
                            target.SetSourceObject(newSingleSource);
                        }
                    }
                }
                else
                {
                    Mesh.SetSourceObject(newSingleSource);
                }
            }

            GUI.Separator();
        }
예제 #18
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();
        }
예제 #19
0
        public static void OnObjectListsGUI(ScriptComponent context, GUISkin skin)
        {
            if (context == null)
            {
                return;
            }

            RigidBodyTool.OnRigidBodyListGUI(context.GetComponentsInChildren <RigidBody>(), context, skin);

            GUI.Separator();

            RigidBodyTool.OnConstraintListGUI(context.GetComponentsInChildren <Constraint>(), context, skin);

            GUI.Separator();

            RigidBodyTool.OnShapeListGUI(context.GetComponentsInChildren <AGXUnity.Collide.Shape>(), context, skin);
        }
예제 #20
0
        public override void OnInspectorGUI()
        {
            if (Utils.KeyHandler.HandleDetectKeyOnGUI(this.targets, Event.current))
            {
                return;
            }

            var selected = from obj in this.targets select obj as CableProperties;

            if (selected.Count() == 0)
            {
                return;
            }

            Undo.RecordObjects(selected.ToArray(), "Cable properties");

            var skin = InspectorEditor.Skin;

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

            GUI.Separator();

            Tuple <PropertyWrapper, CableProperties.Direction, object> changed = null;

            using (new GUI.Indent(12)) {
                foreach (CableProperties.Direction dir in CableProperties.Directions)
                {
                    var tmp = OnPropertyGUI(dir, selected.First(), skin);
                    if (tmp != null)
                    {
                        changed = tmp;
                    }
                    GUI.Separator();
                }
            }

            if (changed != null)
            {
                foreach (var properties in selected)
                {
                    changed.Item1.ConditionalSet(properties[changed.Item2], changed.Item3);
                    EditorUtility.SetDirty(properties);
                }
            }
        }
예제 #21
0
        public static void OnObjectListsGUI(CustomTargetTool context)
        {
            if (context == null)
            {
                return;
            }

            RigidBodyTool.OnRigidBodyListGUI(context.CollectComponentsInChildred <RigidBody>().ToArray(), context);

            GUI.Separator();

            RigidBodyTool.OnConstraintListGUI(context.CollectComponentsInChildred <Constraint>().ToArray(), context);

            GUI.Separator();

            RigidBodyTool.OnShapeListGUI(context.CollectComponentsInChildred <Shape>().ToArray(), context);
        }
예제 #22
0
        public override void OnPostTargetMembersGUI()
        {
            var skin = InspectorEditor.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(RigidBody.GetComponentsInChildren <Shape>(), this);

            GUI.Separator();

            OnConstraintListGUI(m_constraints.ToArray(), this);
        }
예제 #23
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);
        }
예제 #24
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();
        }
예제 #25
0
        public void OnInspectorGUI(bool onlyNameAndMaterial = false)
        {
            var skin = InspectorEditor.Skin;

            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;
                }
            }
        }
예제 #26
0
        public static void OnRigidBodyListGUI(RigidBody[] rigidBodies, CustomTargetTool context)
        {
            var skin = InspectorEditor.Skin;

            if (!GUI.Foldout(EditorData.Instance.GetData(context.Targets[0], "Rigid Bodies"),
                             GUI.MakeLabel("Rigid Bodies", true), skin))
            {
                context.RemoveEditors(rigidBodies);
                return;
            }

            if (rigidBodies.Length == 0)
            {
                using (new GUI.Indent(12))
                    GUILayout.Label(GUI.MakeLabel("Empty", true), skin.label);
                return;
            }

            using (new GUI.Indent(12)) {
                foreach (var rb in rigidBodies)
                {
                    GUI.Separator();

                    if (!GUI.Foldout(EditorData.Instance.GetData(context.Targets[0], rb.GetInstanceID().ToString()),
                                     GUI.MakeLabel("[" + GUI.AddColorTag("RigidBody", Color.Lerp(Color.blue, Color.white, 0.35f)) + "] " + rb.name),
                                     skin))
                    {
                        context.RemoveEditor(rb);
                        continue;
                    }

                    GUI.Separator();

                    using (new GUI.Indent(12)) {
                        var editor = context.GetOrCreateEditor(rb);
                        editor.OnInspectorGUI();
                    }
                }
            }
        }
예제 #27
0
        public static void OnShapeListGUI(Shape[] shapes, CustomTargetTool context)
        {
            var skin = InspectorEditor.Skin;

            if (!GUI.Foldout(EditorData.Instance.GetData(context.Targets[0], "Shapes"), GUI.MakeLabel("Shapes", true), skin))
            {
                context.RemoveEditors(shapes);
                return;
            }

            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(context.Targets[0],
                                                                 shape.GetInstanceID().ToString()),
                                     GUI.MakeLabel("[" + GUI.AddColorTag(shape.GetType().Name, Color.Lerp(Color.green, Color.black, 0.4f)) + "] " + shape.name),
                                     skin))
                    {
                        context.RemoveEditor(shape);
                        continue;
                    }

                    GUI.Separator();
                    using (new GUI.Indent(12)) {
                        var editor = context.GetOrCreateEditor(shape);
                        using (new GUILayout.VerticalScope())
                            editor.OnInspectorGUI();
                    }
                }
            }
        }
        public override void OnPreTargetMembersGUI()
        {
            var skin           = InspectorEditor.Skin;
            var directory      = AssetDatabase.GUIDToAssetPath(RestoredAGXFile.DataDirectoryId);
            var directoryValid = directory.Length > 0 && AssetDatabase.IsValidFolder(directory);

            using (new GUILayout.HorizontalScope()) {
                GUILayout.Label(GUI.MakeLabel("Data directory"), skin.label, GUILayout.Width(160));

                var statusColor = directoryValid ?
                                  Color.Lerp(Color.white, Color.green, 0.2f) :
                                  Color.Lerp(Color.white, Color.red, 0.2f);
                var prevColor = UnityEngine.GUI.backgroundColor;

                UnityEngine.GUI.backgroundColor = statusColor;
                GUILayout.TextField(directory, skin.textField);
                UnityEngine.GUI.backgroundColor = prevColor;
                if (GUILayout.Button(GUI.MakeLabel("...", false, "Open file panel"),
                                     skin.button,
                                     GUILayout.Width(28)))
                {
                    var newDirectory = EditorUtility.OpenFolderPanel("Prefab data directory", "Assets", "");
                    if (newDirectory.Length > 0)
                    {
                        var relPath = IO.Utils.MakeRelative(newDirectory, Application.dataPath).Replace('\\', '/');
                        if (AssetDatabase.IsValidFolder(relPath))
                        {
                            RestoredAGXFile.DataDirectoryId = AssetDatabase.AssetPathToGUID(relPath);
                            EditorUtility.SetDirty(RestoredAGXFile);
                        }
                    }
                }
            }

            GUI.Separator();

            AssemblyTool.OnObjectListsGUI(this);
        }
예제 #29
0
        public override void OnPostTargetMembersGUI()
        {
            var skin = InspectorEditor.Skin;

            var beginWinches = GetTargets <Wire, WireWinch>(wire => wire.BeginWinch).Where(winch => winch != null);
            var endWinches   = GetTargets <Wire, WireWinch>(wire => wire.EndWinch).Where(winch => winch != null);

            if (beginWinches.Count() > 0)
            {
                GUI.Separator();
                GUILayout.Label(GUI.MakeLabel("Begin winch", true), skin.label);
                using (new GUI.Indent(12)) {
                    if (beginWinches.Count() != NumTargets)
                    {
                        AGXUnity.Utils.GUI.WarningLabel("Not all selected wires has a begin winch.", skin);
                    }
                    InspectorEditor.DrawMembersGUI(beginWinches.ToArray());
                }
                GUI.Separator();
            }
            if (endWinches.Count() > 0)
            {
                if (beginWinches.Count() == 0)
                {
                    GUI.Separator();
                }

                GUILayout.Label(GUI.MakeLabel("End winch", true), skin.label);
                using (new GUI.Indent(12)) {
                    if (endWinches.Count() != NumTargets)
                    {
                        AGXUnity.Utils.GUI.WarningLabel("Not all selected wires has an end winch.", skin);
                    }
                    InspectorEditor.DrawMembersGUI(endWinches.ToArray());
                }
                GUI.Separator();
            }
        }
예제 #30
0
        public static void OnRigidBodyListGUI(RigidBody[] rigidBodies, UnityEngine.Object context, GUISkin skin)
        {
            if (!GUI.Foldout(EditorData.Instance.GetData(context, "Rigid Bodies"), GUI.MakeLabel("Rigid Bodies", true), skin))
            {
                return;
            }

            if (rigidBodies.Length == 0)
            {
                using (new GUI.Indent(12))
                    GUILayout.Label(GUI.MakeLabel("Empty", true), skin.label);
                return;
            }

            using (new GUI.Indent(12)) {
                foreach (var rb in rigidBodies)
                {
                    GUI.Separator();

                    if (!GUI.Foldout(EditorData.Instance.GetData(context, rb.GetInstanceID().ToString()),
                                     GUI.MakeLabel("[" + GUI.AddColorTag("RigidBody", Color.Lerp(Color.blue, Color.white, 0.35f)) + "] " + rb.name),
                                     skin))
                    {
                        continue;
                    }

                    GUI.Separator();
                    var rbTool = new RigidBodyTool(rb)
                    {
                        ToolsActive = false
                    };
                    using (new GUI.Indent(12)) {
                        rbTool.OnPreTargetMembersGUI(skin);
                        BaseEditor <RigidBody> .Update(rb, rb, skin);
                    }
                }
            }
        }