Beispiel #1
0
        public override void OnGUI()
        {
            if (settings == null || editorSettings == null)
            {
                Init();
            }

            var style = EditorStyle.Get;

            EditorGUI.BeginChangeCheck();

            EditorGUILayout.BeginVertical(style.area);

            GUILayout.Label("Runtime Settings", style.heading);

            EditorGUILayout.BeginVertical(style.area);

            ES3SettingsEditor.Draw(settings);

            EditorGUILayout.EndVertical();

            GUILayout.Label("Editor Settings", style.heading);

            EditorGUILayout.BeginVertical(style.area);

            var wideLabel = new GUIStyle();

            wideLabel.fixedWidth = 400;

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.PrefixLabel("Auto Add Manager to Scene", wideLabel);
            editorSettings.addMgrToSceneAutomatically = EditorGUILayout.Toggle(editorSettings.addMgrToSceneAutomatically);
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.PrefixLabel("Auto Update References", wideLabel);
            editorSettings.autoUpdateReferences = EditorGUILayout.Toggle(editorSettings.autoUpdateReferences);
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.Space();


            // Show Assembly names array.
            SerializedObject   so = new SerializedObject(editorSettings);
            SerializedProperty settingsProperty      = so.FindProperty("settings");
            SerializedProperty assemblyNamesProperty = settingsProperty.FindPropertyRelative("assemblyNames");

            EditorGUILayout.PropertyField(assemblyNamesProperty, new GUIContent("Assemblies containing ES3Types", "The names of assemblies we want to load ES3Types from."), true);             // True means show children
            so.ApplyModifiedProperties();

            EditorGUILayout.EndVertical();

            EditorGUILayout.EndVertical();


            if (EditorGUI.EndChangeCheck())
            {
                EditorUtility.SetDirty(editorSettings);
            }
        }
Beispiel #2
0
        public override void OnGUI()
        {
            if (mgr == null)
            {
                Init();
            }

            if (mgr == null)
            {
                EditorGUILayout.LabelField("Enable Auto Save for Scene");
                return;
            }

            var style = EditorStyle.Get;

            EditorGUI.BeginChangeCheck();

            EditorGUILayout.BeginVertical(style.area);

            GUILayout.Label("Settings for Current Scene", style.heading);

            EditorGUILayout.BeginVertical(style.area);

            mgr.saveEvent = (ES3AutoSaveMgr.SaveEvent)EditorGUILayout.EnumPopup("Save Event", mgr.saveEvent);
            mgr.loadEvent = (ES3AutoSaveMgr.LoadEvent)EditorGUILayout.EnumPopup("Load Event", mgr.loadEvent);

            mgr.key = EditorGUILayout.TextField("Key", mgr.key);

            EditorGUILayout.Space();

            showAdvancedSettings = EditorGUILayout.Foldout(showAdvancedSettings, "Show Advanced Settings");
            if (showAdvancedSettings)
            {
                EditorGUI.indentLevel++;
                ES3SettingsEditor.Draw(mgr.settings);
                EditorGUI.indentLevel--;
            }

            EditorGUILayout.EndVertical();

            if (EditorGUI.EndChangeCheck())
            {
                EditorUtility.SetDirty(mgr);
            }

            EditorGUILayout.EndVertical();
        }
Beispiel #3
0
        public override void OnGUI()
        {
            Init();

            if (mgr == null)
            {
                EditorGUILayout.Space();
                if (GUILayout.Button("Enable Auto Save for this scene"))
                {
                    mgr = ES3Postprocessor.AddManagerToScene().GetComponent <ES3AutoSaveMgr>();
                }
                else
                {
                    return;
                }
            }

            var style = EditorStyle.Get;

            using (var changeCheck = new EditorGUI.ChangeCheckScope())
            {
                using (var vertical = new EditorGUILayout.VerticalScope(style.areaPadded))
                {
                    //GUILayout.Label("Settings for current scene", style.heading);
                    mgr.saveEvent = (ES3AutoSaveMgr.SaveEvent)EditorGUILayout.EnumPopup("Save Event", mgr.saveEvent);
                    mgr.loadEvent = (ES3AutoSaveMgr.LoadEvent)EditorGUILayout.EnumPopup("Load Event", mgr.loadEvent);

                    EditorGUILayout.Space();

                    showAdvancedSettings = EditorGUILayout.Foldout(showAdvancedSettings, "Show Advanced Settings");
                    if (showAdvancedSettings)
                    {
                        EditorGUI.indentLevel++;
                        mgr.key = EditorGUILayout.TextField("Key", mgr.key);
                        ES3SettingsEditor.Draw(mgr.settings);
                        EditorGUI.indentLevel--;
                    }
                }

                // Display the menu.
                using (var horizontal = new EditorGUILayout.HorizontalScope())
                {
                    if (GUILayout.Button("Scene", sceneOpen ? style.menuButtonSelected : style.menuButton))
                    {
                        sceneOpen = true;
                        OnFocus();
                    }
                    if (GUILayout.Button("Prefabs", sceneOpen ? style.menuButton : style.menuButtonSelected))
                    {
                        sceneOpen = false;
                        OnFocus();
                    }
                }

                //EditorGUILayout.HelpBox("Select the Components you want to be saved.\nTo maximise performance, only select the Components with variables which need persisting.", MessageType.None, true);

                if (hierarchy == null || hierarchy.Length == 0)
                {
                    EditorGUILayout.LabelField("Right-click a prefab and select 'Easy Save 3 > Enable Easy Save for Scene' to enable Auto Save for it.\n\nYour scene will also need to reference this prefab for it to be recognised.", style.area);
                    return;
                }

                using (var scrollView = new EditorGUILayout.ScrollViewScope(hierarchyScrollPosition, style.areaPadded))
                {
                    hierarchyScrollPosition = scrollView.scrollPosition;

                    using (new EditorGUILayout.HorizontalScope(GUILayout.Width(200)))
                    {
                        searchTerm = GUILayout.TextField(searchTerm, GUI.skin.FindStyle("ToolbarSeachTextField"));
                        if (GUILayout.Button("", GUI.skin.FindStyle("ToolbarSeachCancelButton")))
                        {
                            // Remove focus if cleared
                            searchTerm = "";
                            GUI.FocusControl(null);
                        }
                    }

                    EditorGUILayout.Space();
                    EditorGUILayout.Space();

                    foreach (var go in hierarchy)
                    {
                        if (go != null)
                        {
                            go.DrawHierarchy(searchTerm.ToLowerInvariant());
                        }
                    }
                }
                if (changeCheck.changed)
                {
                    EditorUtility.SetDirty(mgr);
                }
            }
        }
Beispiel #4
0
        public override void OnGUI()
        {
            if (settings == null || editorSettings == null || assemblyNamesProperty == null)
            {
                Init();
            }

            var style = EditorStyle.Get;

            EditorGUI.BeginChangeCheck();

            EditorGUILayout.BeginVertical(style.area);

            GUILayout.Label("Runtime Settings", style.heading);

            EditorGUILayout.BeginVertical(style.area);

            ES3SettingsEditor.Draw(settings);

            EditorGUILayout.EndVertical();

            var wideLabel = new GUIStyle();

            wideLabel.fixedWidth = 400;

            GUILayout.Label("Debug Settings", style.heading);

            EditorGUILayout.BeginVertical(style.area);

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.PrefixLabel("Log Warnings", wideLabel);
            editorSettings.logWarnings = EditorGUILayout.Toggle(editorSettings.logWarnings);
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.Space();
            EditorGUILayout.EndVertical();

            GUILayout.Label("Editor Settings", style.heading);

            EditorGUILayout.BeginVertical(style.area);

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.PrefixLabel("Auto Add Manager to Scene", wideLabel);
            editorSettings.addMgrToSceneAutomatically = EditorGUILayout.Toggle(editorSettings.addMgrToSceneAutomatically);
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.PrefixLabel("Auto Update References", wideLabel);
            editorSettings.autoUpdateReferences = EditorGUILayout.Toggle(editorSettings.autoUpdateReferences);
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.Space();


            // Show Assembly names array.
            //EditorGUILayout.PropertyField(assemblyNamesProperty, new GUIContent("Assemblies containing ES3Types", "The names of assemblies we want to load ES3Types from."), true); // True means show children

            /*if(so.ApplyModifiedProperties())
             * {
             #if UNITY_2018_3_OR_NEWER
             *      PrefabUtility.SaveAsPrefabAsset(defaultSettingsGo,ES3Settings.PathToDefaultSettings());
             #endif
             * }*/

            EditorGUILayout.EndVertical();

            EditorGUILayout.EndVertical();


            if (EditorGUI.EndChangeCheck())
            {
                EditorUtility.SetDirty(editorSettings);
            }
        }
Beispiel #5
0
        public override void OnGUI()
        {
            if (settings == null || editorSettings == null || assemblyNamesProperty == null)
            {
                Init();
            }

            var style = EditorStyle.Get;

            var labelWidth = EditorGUIUtility.labelWidth;


            EditorGUI.BeginChangeCheck();

            using (var scrollView = new EditorGUILayout.ScrollViewScope(scrollPos, style.area))
            {
                scrollPos = scrollView.scrollPosition;

                EditorGUIUtility.labelWidth = 160;

                GUILayout.Label("Runtime Settings", style.heading);

                using (new EditorGUILayout.VerticalScope(style.area))
                {
                    ES3SettingsEditor.Draw(settings);
                }

                GUILayout.Label("Debug Settings", style.heading);

                using (new EditorGUILayout.VerticalScope(style.area))
                {
                    EditorGUIUtility.labelWidth = 100;

                    using (new EditorGUILayout.HorizontalScope())
                    {
                        EditorGUILayout.PrefixLabel("Log Info");
                        editorSettings.logDebugInfo = EditorGUILayout.Toggle(editorSettings.logDebugInfo);
                    }

                    using (new EditorGUILayout.HorizontalScope())
                    {
                        EditorGUILayout.PrefixLabel("Log Warnings");
                        editorSettings.logWarnings = EditorGUILayout.Toggle(editorSettings.logWarnings);
                    }

                    using (new EditorGUILayout.HorizontalScope())
                    {
                        EditorGUILayout.PrefixLabel("Log Errors");
                        editorSettings.logErrors = EditorGUILayout.Toggle(editorSettings.logErrors);
                    }

                    EditorGUILayout.Space();
                }

                GUILayout.Label("Editor Settings", style.heading);

                using (new EditorGUILayout.VerticalScope(style.area))
                {
                    EditorGUIUtility.labelWidth = 170;

                    using (new EditorGUILayout.HorizontalScope())
                    {
                        EditorGUILayout.PrefixLabel("Auto Update References");
                        editorSettings.autoUpdateReferences = EditorGUILayout.Toggle(editorSettings.autoUpdateReferences);
                    }

                    using (new EditorGUILayout.HorizontalScope())
                    {
                        EditorGUILayout.PrefixLabel("Use Global References");

                        var  symbols             = PlayerSettings.GetScriptingDefineSymbolsForGroup(EditorUserBuildSettings.selectedBuildTargetGroup);
                        bool useGlobalReferences = !symbols.Contains("ES3GLOBAL_DISABLED");
                        if (EditorGUILayout.Toggle(useGlobalReferences) != useGlobalReferences)
                        {
                            // Remove the existing symbol even if we're disabling global references, just incase it's already in there.
                            symbols = symbols.Replace("ES3GLOBAL_DISABLED;", ""); // With semicolon
                            symbols = symbols.Replace("ES3GLOBAL_DISABLED", "");  // Without semicolon

                            // Add the symbol if useGlobalReferences is currently true, meaning that we want to disable it.
                            if (useGlobalReferences)
                            {
                                symbols = "ES3GLOBAL_DISABLED;" + symbols;
                            }

                            PlayerSettings.SetScriptingDefineSymbolsForGroup(EditorUserBuildSettings.selectedBuildTargetGroup, symbols);

                            if (useGlobalReferences)
                            {
                                EditorUtility.DisplayDialog("Global references disabled for build platform", "This will only disable Global References for this build platform. To disable it for other build platforms, open that platform in the Build Settings and uncheck this box again.", "Ok");
                            }
                        }
                    }

                    using (new EditorGUILayout.HorizontalScope())
                    {
                        EditorGUILayout.PrefixLabel("Add All Prefabs to Manager");
                        editorSettings.addAllPrefabsToManager = EditorGUILayout.Toggle(editorSettings.addAllPrefabsToManager);
                    }

                    EditorGUILayout.Space();
                }
            }

            if (EditorGUI.EndChangeCheck())
            {
                EditorUtility.SetDirty(editorSettings);
            }

            EditorGUIUtility.labelWidth = labelWidth; // Set the label width back to default
        }