コード例 #1
0
    /*
     *  Adds an ES2 Auto Save Manager object to the current scene.
     */
    public static void AddManagerToScene()
    {
        GameObject managerPrefab = GetManagerPrefab();
        GameObject instance      = PrefabUtility.InstantiatePrefab(managerPrefab) as GameObject;

        PrefabUtility.DisconnectPrefabInstance(instance);
        ES2EditorAutoSaveUtility.mgr = instance.GetComponent <ES2AutoSaveManager>();
        if (AutoSaveComponentsAreHidden())
        {
            instance.hideFlags = HideFlags.HideInHierarchy;
        }
    }
コード例 #2
0
    public void Awake()
    {
        ES2AutoSaveManager._instance = this;

        for (int i = 0; i < sceneObjects.Length; i++)
        {
            ES2AutoSave autoSave = sceneObjects[i];
            if (autoSave == null)
            {
                continue;
            }
            autoSaves[autoSave.id]         = autoSave;
            transforms[autoSave.transform] = autoSave;
        }
    }
コード例 #3
0
    public void Draw()
    {
        ES2EditorWindowStyle style = ES2EditorWindow.instance.style;

        // Don't allow Auto Save to be modified when playing.
        if (Application.isPlaying)
        {
            EditorGUILayout.BeginHorizontal(style.windowContentStyle);
            GUIStyle centerStyle = new GUIStyle(style.contentTextStyle);
            centerStyle.stretchHeight = true;
            centerStyle.alignment     = TextAnchor.MiddleCenter;
            EditorGUILayout.LabelField("Auto Save can not be modified in Play mode.", centerStyle);
            EditorGUILayout.EndHorizontal();
            return;
        }

        // If a manager hasn't been added to the scene, require that it is added.
        ES2AutoSaveManager mgr = ES2EditorAutoSaveUtility.mgr;

        if (mgr == null)
        {
            EditorGUILayout.BeginVertical(style.windowContentStyle);
            if (ES2EditorUtility.Button("Click to enable Auto Save for this scene"))
            {
                ES2EditorAutoSaveUtility.AddManagerToScene();
            }
            EditorGUILayout.EndVertical();
            return;
        }

        Undo.RecordObject(mgr, "Auto Save Settings");

        EditorGUILayout.BeginVertical(style.windowContentStyle);

        EditorGUILayout.BeginHorizontal(style.sectionStyle);
        mgr.loadEvent = (ES2AutoSaveManager.LoadEvent)ES2EditorUtility.EnumField("When to Load", mgr.loadEvent);
        mgr.saveEvent = (ES2AutoSaveManager.SaveEvent)ES2EditorUtility.EnumField("When to Save", mgr.saveEvent);
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.BeginHorizontal(style.sectionStyle);
        mgr.filePath = ES2EditorUtility.TextField("Filename/Path", mgr.filePath);
        mgr.tag      = ES2EditorUtility.TextField("Tag", mgr.tag);
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.BeginVertical(style.sectionStyle);

        mgr.encrypt = ES2EditorUtility.Toggle("Use Encryption", mgr.encrypt);


        if (mgr.encrypt)
        {
            EditorGUILayout.BeginHorizontal(style.indentStyle);
            mgr.encryptionPassword = ES2EditorUtility.TextField("Encryption Password", mgr.encryptionPassword);
            mgr.encryptionType     = (ES2Settings.EncryptionType)ES2EditorUtility.EnumField("Encryption Type", mgr.encryptionType);
            EditorGUILayout.EndHorizontal();
        }

        EditorGUILayout.EndVertical();

        EditorGUILayout.BeginHorizontal(style.sectionStyle);

        mgr.deletePrefabsOnLoad = ES2EditorUtility.Toggle("Delete Instantiated Prefabs on Load", mgr.deletePrefabsOnLoad);
        mgr.convertPrefabsToSceneObjectsOnImport = ES2EditorUtility.Toggle("Convert Prefabs To Scene Objects Upon Dragging Into Scene", mgr.convertPrefabsToSceneObjectsOnImport);

        EditorGUILayout.EndHorizontal();

        EditorGUILayout.BeginHorizontal(style.sectionStyle);

        bool autoSaveComponentsAreHidden = ES2EditorAutoSaveUtility.AutoSaveComponentsAreHidden();

        if (ES2EditorUtility.Toggle("Hide Auto Save Components in Editor", autoSaveComponentsAreHidden) != autoSaveComponentsAreHidden)
        {
            ES2EditorAutoSaveUtility.ToggleHideAutoSaveComponents();
        }

        ES2EditorAutoSaveUtility.AutomaticallyRefreshSceneAutoSaves = ES2EditorUtility.Toggle("Automatically refresh Auto Saves when window is open", ES2EditorAutoSaveUtility.AutomaticallyRefreshSceneAutoSaves);

        EditorGUILayout.EndHorizontal();

        EditorGUILayout.BeginHorizontal(style.sectionStyle);
        if (ES2EditorUtility.Button("Refresh Auto Saves in Scene"))
        {
            ES2EditorAutoSaveUtility.RefreshSceneAutoSaves();
        }

        if (ES2EditorUtility.Button("Refresh Auto Saves in Prefabs"))
        {
            ES2EditorAutoSaveUtility.RefreshPrefabAutoSaves();
        }
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.BeginHorizontal();

        if (ES2EditorUtility.Button("Remove Auto Save from Scene"))
        {
            ES2EditorAutoSaveUtility.RemoveAutoSaveFromScene();
        }
        if (ES2EditorUtility.Button("Remove Auto Save from all Prefabs"))
        {
            ES2EditorAutoSaveUtility.RemoveAutoSaveFromAllPrefabs();
        }
        EditorGUILayout.EndHorizontal();


        EditorGUILayout.EndVertical();
    }
コード例 #4
0
    public override void Read(ES2Reader reader, object obj)
    {
        ES2AutoSaveManager mgr = (ES2AutoSaveManager)obj;

        mgr.ReadAutoSaves(reader);
    }
コード例 #5
0
    public override void Write(object data, ES2Writer writer)
    {
        ES2AutoSaveManager mgr = (ES2AutoSaveManager)data;

        mgr.WriteAutoSaves(writer);
    }