Esempio n. 1
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();
        }
Esempio n. 2
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();
        }
Esempio n. 3
0
        private void HandleModeConstraintGUI(GUISkin skin)
        {
            if (ConstraintCreateTool == null)
            {
                ChangeMode(Mode.None);
                return;
            }

            GUI.Separator3D();

            ConstraintCreateTool.OnInspectorGUI(skin);
        }
Esempio n. 4
0
        private void HandleModeShapeGUI(GUISkin skin)
        {
            if (ShapeCreateTool == null)
            {
                ChangeMode(Mode.None);
                return;
            }

            GUI.Separator3D();

            ShapeCreateTool.OnInspectorGUI(skin);
        }
Esempio n. 5
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);
        }
Esempio n. 6
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);
        }
Esempio n. 7
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.Separator3D();
        }
Esempio n. 8
0
        private void OnContactMaterialsList()
        {
            var             skin = InspectorEditor.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 +
                                                                                        "_" +
                                                                                        contactMaterial.GetInstanceID().ToString()),
                                                            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))
                                    InspectorEditor.DrawMembersGUI(new Object[] { contactMaterial });
                            }
                        }
                    }
                }
            }
            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);
            }
        }
        public void OnInspectorGUI(GUISkin skin)
        {
            if (AttachmentFrameTool == null || AttachmentFrameTool.AttachmentPair == null)
            {
                PerformRemoveFromParent();
                return;
            }

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

                GUILayout.BeginHorizontal();
                {
                    GUILayout.Label(GUI.MakeLabel("Type", true), skin.label, GUILayout.Width(64));
                    using (new GUI.ColorBlock(Color.Lerp(UnityEngine.GUI.color, Color.yellow, 0.1f)))
                        m_createConstraintData.ConstraintType = (ConstraintType)EditorGUILayout.EnumPopup(m_createConstraintData.ConstraintType, skin.button, GUILayout.ExpandWidth(true), GUILayout.Height(18));
                }
                GUILayout.EndHorizontal();
            }

            GUI.Separator3D();

            AttachmentFrameTool.OnPreTargetMembersGUI(skin);
            AttachmentFrameTool.AttachmentPair.Synchronize();

            m_createConstraintData.CollisionState = ConstraintTool.ConstraintCollisionsStateGUI(m_createConstraintData.CollisionState, skin);
            m_createConstraintData.SolveType      = ConstraintTool.ConstraintSolveTypeGUI(m_createConstraintData.SolveType, skin);

            GUI.Separator3D();

            var createCancelState = GUI.CreateCancelButtons(m_createConstraintData.AttachmentPair.ReferenceObject != null &&
                                                            m_createConstraintData.AttachmentPair.ReferenceObject.GetComponentInParent <RigidBody>() != null,
                                                            skin,
                                                            "Create the constraint");

            GUI.Separator3D();

            if (createCancelState == GUI.CreateCancelState.Create)
            {
                GameObject constraintGameObject = Factory.Create(m_createConstraintData.ConstraintType,
                                                                 m_createConstraintData.AttachmentPair);
                Constraint constraint = constraintGameObject.GetComponent <Constraint>();
                constraintGameObject.name  = m_createConstraintData.Name;
                constraint.CollisionsState = m_createConstraintData.CollisionState;

                if (MakeConstraintChildToParent)
                {
                    constraintGameObject.transform.SetParent(Parent.transform);
                }

                Undo.RegisterCreatedObjectUndo(constraintGameObject, "New constraint '" + constraintGameObject.name + "' created");

                m_createConstraintData.Reset();
            }

            if (createCancelState != GUI.CreateCancelState.Nothing)
            {
                PerformRemoveFromParent();
            }
        }
Esempio n. 10
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);
            }
        }
        public override void OnPreTargetMembersGUI()
        {
            var  skin          = InspectorEditor.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);
                }
            }
        }