Beispiel #1
0
    public static GameObject AddManagerToScene()
    {
        var go = GameObject.Find("Easy Save 3 Manager");

        if (go == null)
        {
            go = new GameObject("Easy Save 3 Manager");
            var inspectorInfo = go.AddComponent <ES3InspectorInfo>();
            inspectorInfo.message = "The Easy Save 3 Manager is required in any scenes which use Easy Save, and is automatically added to your scene when you enter Play mode.\n\nTo stop this from automatically being added to your scene, go to 'Window > Easy Save 3 > Settings' and deselect the 'Auto Add Manager to Scene' checkbox.";



            _refMgr      = go.AddComponent <ES3ReferenceMgr>();
            _autoSaveMgr = go.AddComponent <ES3AutoSaveMgr>();
            Undo.RegisterCreatedObjectUndo(go, "Enabled Easy Save for Scene");
        }
        else
        {
            _refMgr = go.GetComponent <ES3ReferenceMgr>();
            if (_refMgr == null)
            {
                _refMgr = go.AddComponent <ES3ReferenceMgr>();
                Undo.RegisterCreatedObjectUndo(_refMgr, "Enabled Easy Save for Scene");
            }

            _autoSaveMgr = go.GetComponent <ES3AutoSaveMgr>();
            if (_autoSaveMgr == null)
            {
                _autoSaveMgr = go.AddComponent <ES3AutoSaveMgr>();
                Undo.RegisterCreatedObjectUndo(_autoSaveMgr, "Enabled Easy Save for Scene");
            }
        }
        return(go);
    }
Beispiel #2
0
 public void OnDestroy()
 {
     // If this is being destroyed, but not because the application is quitting,
     // remove the AutoSave from the manager.
     if (!isQuitting)
     {
         ES3AutoSaveMgr.RemoveAutoSave(this);
     }
 }
    public void Awake()
    {
        _instance = this;

        if (loadEvent == LoadEvent.Awake)
        {
            Load();
        }
    }
Beispiel #4
0
        public void Init()
        {
            var mgrs = Resources.FindObjectsOfTypeAll <ES3AutoSaveMgr>();

            if (mgrs.Length > 0)
            {
                mgr = mgrs[0];
            }
        }
Beispiel #5
0
 public void Awake()
 {
     if (ES3AutoSaveMgr.Instance == null)
     {
         ES3Internal.ES3Debug.LogWarning("<b>No GameObjects in this scene will be autosaved</b> because there is no Easy Save 3 Manager. To add a manager to this scene, exit playmode and go to Assets > Easy Save 3 > Add Manager to Scene.", this);
     }
     else
     {
         ES3AutoSaveMgr.AddAutoSave(this);
     }
 }
Beispiel #6
0
    public static GameObject AddManagerToScene()
    {
        if (_refMgr != null)
        {
            return(_refMgr.gameObject);
        }

        var mgr = GameObject.Find("Easy Save 3 Manager");

        if (mgr == null)
        {
            mgr = new GameObject("Easy Save 3 Manager");
            var inspectorInfo = mgr.AddComponent <ES3InspectorInfo>();
            inspectorInfo.message = "The Easy Save 3 Manager is required in any scenes which use Easy Save, and is automatically added to your scene when you enter Play mode.\n\nTo stop this from automatically being added to your scene, go to 'Window > Easy Save 3 > Settings' and deselect the 'Auto Add Manager to Scene' checkbox.";

            _refMgr      = mgr.AddComponent <ES3ReferenceMgr>();
            _autoSaveMgr = mgr.AddComponent <ES3AutoSaveMgr>();

            foreach (var obj in EditorSceneManager.GetActiveScene().GetRootGameObjects())
            {
                if (obj != mgr && !changedSinceLastSave.Contains(obj))
                {
                    changedSinceLastSave.Enqueue(obj);
                }
            }

            _refMgr.GeneratePrefabReferences();

            Undo.RegisterCreatedObjectUndo(mgr, "Enabled Easy Save for Scene");
        }
        else
        {
            _refMgr = mgr.GetComponent <ES3ReferenceMgr>();
            if (_refMgr == null)
            {
                _refMgr = mgr.AddComponent <ES3ReferenceMgr>();
                Undo.RegisterCreatedObjectUndo(_refMgr, "Enabled Easy Save for Scene");
            }

            _autoSaveMgr = mgr.GetComponent <ES3AutoSaveMgr>();
            if (_autoSaveMgr == null)
            {
                _autoSaveMgr = mgr.AddComponent <ES3AutoSaveMgr>();
                Undo.RegisterCreatedObjectUndo(_autoSaveMgr, "Enabled Easy Save for Scene");
            }
        }
        return(mgr);
    }
    public void Awake()
    {
        autoSaves = new HashSet <ES3AutoSave>();

        foreach (var go in this.gameObject.scene.GetRootGameObjects())
        {
            autoSaves.UnionWith(go.GetComponentsInChildren <ES3AutoSave>(true));
        }

        _current = this;

        if (loadEvent == LoadEvent.Awake)
        {
            Load();
        }
    }
Beispiel #8
0
        public void Init()
        {
            if (mgr == null)
            {
                var mgrs = Resources.FindObjectsOfTypeAll <ES3AutoSaveMgr>();
                if (mgrs.Length > 0)
                {
                    mgr = mgrs[0];
                }
            }

            if (hierarchy == null)
            {
                OnFocus();
            }
        }
    public void Awake()
    {
        autoSaves = new HashSet <ES3AutoSave>();

        foreach (var go in SceneManager.GetActiveScene().GetRootGameObjects())
        {
            autoSaves.UnionWith(go.GetComponentsInChildren <ES3AutoSave>(true));
        }

        _instance = this;

        if (loadEvent == LoadEvent.Awake)
        {
            Load();
        }
    }
Beispiel #10
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 #11
0
 public void Awake()
 {
     ES3AutoSaveMgr.AddAutoSave(this);
 }