Ejemplo n.º 1
0
        public override void OnPostTargetMembersGUI()
        {
            var skin = InspectorEditor.Skin;

            Simulation.DisplayStatistics = InspectorGUI.Toggle(GUI.MakeLabel("Display Statistics"), Simulation.DisplayStatistics);
            if (Simulation.DisplayStatistics)
            {
                using (InspectorGUI.IndentScope.Single)
                    Simulation.DisplayMemoryAllocations = InspectorGUI.Toggle(GUI.MakeLabel("Display Memory Allocations"), Simulation.DisplayMemoryAllocations);
            }

            InspectorGUI.Separator(1, 4);

            using (new GUI.EnabledBlock(Application.isPlaying)) {
#if AGXUNITY_DEV_BUILD
                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))
                {
                    saveCurrentState();
                }

                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();
                }
#endif

                var rect     = EditorGUILayout.GetControlRect();
                var orgWidth = rect.width;
                rect.width = EditorGUIUtility.labelWidth;
                EditorGUI.PrefixLabel(rect, GUI.MakeLabel("Save current step as (.agx)"), skin.Label);
                rect.x    += EditorGUIUtility.labelWidth;
                rect.width = orgWidth - EditorGUIUtility.labelWidth;
                if (UnityEngine.GUI.Button(rect, GUI.MakeLabel("Output file..."), 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);
                        }
                    }
                }
            }

            Simulation.SavePreFirstStepPath = InspectorGUI.ToggleSaveFile(GUI.MakeLabel("Dump initial (.agx)"),
                                                                          Simulation.SavePreFirstStep,
                                                                          enabled => Simulation.SavePreFirstStep = enabled,
                                                                          Simulation.SavePreFirstStepPath,
                                                                          UnityEditor.SceneManagement.EditorSceneManager.GetActiveScene().name,
                                                                          "agx",
                                                                          "Path to initial dump (including file name and extension)",
                                                                          fileExtension => fileExtension == ".agx" || fileExtension == ".aagx");

#if AGXUNITY_DEV_ENV
            using (new GUI.EnabledBlock(EditorApplication.isPlaying)) {
                var rect = EditorGUILayout.GetControlRect();
                rect.x     += EditorGUIUtility.labelWidth;
                rect.width -= EditorGUIUtility.labelWidth;
                if (UnityEngine.GUI.Button(rect, GUI.MakeLabel("Open in native viewer..."), skin.Button))
                {
                    ;
                }
            }
#endif
        }