Inheritance: AssetPostprocessor
Exemple #1
0
 public static void EnableForScene()
 {
     if (!SceneManager.GetActiveScene().isLoaded)
     {
         EditorUtility.DisplayDialog("Could not add manager to scene", "Could not add Easy Save 3 Manager to scene because there is not currently a scene open.", "Ok");
     }
     Selection.activeObject = ES3Postprocessor.AddManagerToScene();
 }
    public static void GenerateNewReferences()
    {
        var scene = SceneManager.GetActiveScene();

        if (!scene.isLoaded)
        {
            EditorUtility.DisplayDialog("Could not enable Easy Save", "Could not enable Easy Save because there is not currently a scene open.", "Ok");
        }


        var refMgr = UnityEngine.Object.FindObjectOfType <ES3ReferenceMgr>();

        if (refMgr != null)
        {
            if (!EditorUtility.DisplayDialog("Are you sure you wish to generate new references?", "By doing this, any save files created using these references will no longer work with references in this scene.", "Generate New Reference IDs", "Cancel"))
            {
                return;
            }
            DestroyImmediate(refMgr);
        }

        Selection.activeObject = ES3Postprocessor.AddManagerToScene();
    }
Exemple #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);
                }
            }
        }