Beispiel #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();
        }
Beispiel #2
0
        public static bool ConstraintConnectedFrameSyncGUI(bool enabled, GUISkin skin)
        {
            using (new GUI.Indent(12)) {
                enabled = GUI.Toggle(GUI.MakeLabel("Connected frame animated", true), enabled, skin.button, skin.label);
            }

            return(enabled);
        }
        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);
                    }
                }
            }
        }
Beispiel #4
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);
        }
Beispiel #5
0
        private void HandleConstraintControllerGUI(ElementaryConstraintController controller, GUISkin skin)
        {
            var    controllerType    = controller.GetControllerType();
            var    controllerTypeTag = controllerType.ToString().Substring(0, 1);
            string dimString         = "[" + GUI.AddColorTag(controllerTypeTag,
                                                             controllerType == Constraint.ControllerType.Rotational ?
                                                             Color.Lerp(UnityEngine.GUI.color, Color.red, 0.75f) :
                                                             Color.Lerp(UnityEngine.GUI.color, Color.green, 0.75f)) + "] ";

            if (GUI.Foldout(Selected(SelectedFoldout.Controller,
                                     controllerTypeTag + ConstraintUtils.FindName(controller)),
                            GUI.MakeLabel(dimString + ConstraintUtils.FindName(controller), true),
                            skin,
                            OnFoldoutStateChange))
            {
                using (new GUI.Indent(12)) {
                    controller.Enable = GUI.Toggle(GUI.MakeLabel("Enable", controller.Enable), controller.Enable, skin.button, skin.label);
                    BaseEditor <ElementaryConstraint> .Update(controller, controller, skin);
                }
            }
        }
Beispiel #6
0
        public override void OnPostTargetMembersGUI()
        {
            var skin = InspectorEditor.Skin;

            GUI.Separator();

            Simulation.DisplayStatistics = GUI.Toggle(GUI.MakeLabel("Display Statistics"), Simulation.DisplayStatistics, skin.button, skin.label);
            if (Simulation.DisplayStatistics)
            {
                using (new GUI.Indent(12))
                    Simulation.DisplayMemoryAllocations = GUI.Toggle(GUI.MakeLabel("Display Memory Allocations"), Simulation.DisplayMemoryAllocations, skin.button, skin.label);
            }

            GUI.Separator();

            using (new GUILayout.HorizontalScope()) {
                EditorGUI.BeginDisabledGroup(!Application.isPlaying);
                if (GUILayout.Button(GUI.MakeLabel("Save current step as (.agx)...",
                                                   false,
                                                   "Save scene in native file format when the editor is in play mode."), skin.button))
                {
                    string result = EditorUtility.SaveFilePanel("Save scene as .agx", "Assets",
                                                                UnityEditor.SceneManagement.EditorSceneManager.GetActiveScene().name,
                                                                "agx");
                    if (result != string.Empty)
                    {
                        var success = Simulation.SaveToNativeFile(result);
                        if (success)
                        {
                            Debug.Log(GUI.AddColorTag("Successfully wrote simulation to file: ", Color.green) + result);
                        }
                    }
                }

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

            GUI.Separator();

            Simulation.SavePreFirstStep = GUI.Toggle(GUI.MakeLabel("Dump initial (.agx):"),
                                                     Simulation.SavePreFirstStep,
                                                     skin.button,
                                                     skin.label);
            EditorGUI.BeginDisabledGroup(!Simulation.SavePreFirstStep);
            {
                using (new GUILayout.HorizontalScope()) {
                    GUILayout.Space(26);
                    Simulation.SavePreFirstStepPath = GUILayout.TextField(Simulation.SavePreFirstStepPath, skin.textField);
                    if (GUILayout.Button(GUI.MakeLabel("...", false, "Open file panel"),
                                         skin.button,
                                         GUILayout.Width(28)))
                    {
                        string result = EditorUtility.SaveFilePanel("Path to initial dump (including file name and extension)",
                                                                    SaveInitialPath,
                                                                    UnityEditor.SceneManagement.EditorSceneManager.GetActiveScene().name, "agx");
                        if (result != string.Empty)
                        {
                            SaveInitialPath = result;
                            var fileInfo = new System.IO.FileInfo(SaveInitialPath);
                            if (fileInfo.Extension == ".agx" || fileInfo.Extension == ".aagx")
                            {
                                Simulation.SavePreFirstStepPath = SaveInitialPath;
                            }
                            else
                            {
                                Debug.Log("Unknown file extension: " + fileInfo.Extension);
                            }
                        }
                    }
                }
            }
            EditorGUI.EndDisabledGroup();
        }
Beispiel #7
0
 public static object BoolDrawer(object obj, InvokeWrapper wrapper, GUISkin skin)
 {
     return(GUI.Toggle(MakeLabel(wrapper.Member), wrapper.Get <bool>(obj), skin.button, skin.label));
 }
Beispiel #8
0
        private void HandleKeyHandlerGUI(GUIContent name, Utils.KeyHandler keyHandler, GUISkin skin)
        {
            const int keyButtonWidth = 90;

            GUILayout.BeginHorizontal();
            {
                keyHandler.Enable = GUI.Toggle(name,
                                               keyHandler.Enable,
                                               skin.button,
                                               GUI.Align(skin.label, TextAnchor.MiddleLeft),
                                               new GUILayoutOption[] { GUILayout.Width(ToggleButtonSize), GUILayout.Height(ToggleButtonSize) },
                                               new GUILayoutOption[] { GUILayout.Height(ToggleButtonSize) });
                GUILayout.FlexibleSpace();

                UnityEngine.GUI.enabled = keyHandler.Enable;

                for (int iKey = 0; iKey < keyHandler.NumKeyCodes; ++iKey)
                {
                    GUIContent buttonLabel = keyHandler.IsDetectingKey(iKey) ?
                                             GUI.MakeLabel("Detecting...") :
                                             GUI.MakeLabel(keyHandler.Keys[iKey].ToString());

                    bool toggleDetecting = GUILayout.Button(buttonLabel, skin.button, GUILayout.Width(keyButtonWidth), GUILayout.Height(ToggleButtonSize));
                    if (toggleDetecting)
                    {
                        keyHandler.DetectKey(this, !keyHandler.IsDetectingKey(iKey), iKey);
                    }
                }

                Rect dropDownButtonRect = new Rect();
                GUILayout.BeginVertical(GUILayout.Height(ToggleButtonSize));
                {
                    GUIStyle tmp = new GUIStyle(skin.button);
                    tmp.fontSize = 6;

                    m_showDropDown = GUILayout.Button(GUI.MakeLabel("v", true), tmp, GUILayout.Width(16), GUILayout.Height(14)) ?
                                     !m_showDropDown :
                                     m_showDropDown;
                    dropDownButtonRect = GUILayoutUtility.GetLastRect();
                    GUILayout.FlexibleSpace();
                }
                GUILayout.EndVertical();

                UnityEngine.GUI.enabled = true;

                if (m_showDropDown && dropDownButtonRect.Contains(Event.current.mousePosition))
                {
                    GenericMenu menu = new GenericMenu();
                    menu.AddItem(GUI.MakeLabel("Reset to default"), false, () =>
                    {
                        if (EditorUtility.DisplayDialog("Reset to default", "Reset key(s) to default?", "OK", "Cancel"))
                        {
                            keyHandler.ResetToDefault();
                        }
                    });
                    menu.AddItem(GUI.MakeLabel("Add key"), false, () =>
                    {
                        keyHandler.Add(KeyCode.None);
                    });

                    if (keyHandler.NumKeyCodes > 1)
                    {
                        menu.AddItem(GUI.MakeLabel("Remove key"), false, () =>
                        {
                            if (EditorUtility.DisplayDialog("Remove key", "Remove key: " + keyHandler[keyHandler.NumKeyCodes - 1].ToString() + "?", "OK", "Cancel"))
                            {
                                keyHandler.Remove(keyHandler.NumKeyCodes - 1);
                            }
                        });
                    }

                    menu.ShowAsContext();
                }
            }
            GUILayout.EndHorizontal();

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