示例#1
0
    private static void UpdatePrefabAutoSaveRecursive(ES2AutoSave autoSave)
    {
        // If this prefab has been created from a scene object, or the prefab has been duplicated,
        // generate a new ID for it.
        if (String.IsNullOrEmpty(autoSave.prefabID) || globalMgr.ids.Contains(autoSave.prefabID))
        {
            autoSave.prefabID = ES2AutoSave.GenerateID();
        }

        // If this prefab has been created from a scene object, we'll also need to remove it's id.
        if (!String.IsNullOrEmpty(autoSave.id))
        {
            autoSave.id = "";
        }

        globalMgr.ids.Add(autoSave.prefabID);

        UpdateAutoSave(autoSave);

        foreach (Transform t in autoSave.transform)
        {
            ES2AutoSave childAutoSave = t.GetComponent <ES2AutoSave>();
            if (childAutoSave != null)
            {
                UpdatePrefabAutoSaveRecursive(childAutoSave);
            }
        }
    }
示例#2
0
 public ES2AutoSaveComponentInfo(Component c, ES2AutoSave autoSave)
 {
     this.component   = c;
     this.type        = c.GetType();
     this.name        = this.type.Name;
     this.id          = ES2AutoSave.GenerateID();
     this.autoSave    = autoSave;
     this.isComponent = true;
 }
示例#3
0
 /*
  *  Constructor for displaying instance variables of GameObject.
  */
 public ES2AutoSaveComponentInfo(string name, Type type, ES2AutoSave autoSave)
 {
     this.component   = autoSave;
     this.type        = type;
     this.name        = name;
     this.id          = ES2AutoSave.GenerateID();
     this.autoSave    = autoSave;
     this.isComponent = false;
     this.isProperty  = true;
 }
示例#4
0
 public ES2AutoSaveVariableInfo(string name, Type type, bool isProperty, ES2AutoSave autoSave, ES2AutoSaveVariableInfo previous)
 {
     this.name       = name;
     this.id         = ES2AutoSave.GenerateID();
     this.type       = type;
     this.autoSave   = autoSave;
     this.isProperty = isProperty;
     if (previous != null)
     {
         this.previousID = previous.id;
     }
 }
示例#5
0
    /*
     *  Refreshes the variables and Components for all Auto Saves in this scene.
     *  Should be called after a change is made to the scene, or scripts are recompiled.
     */
    public static void RefreshSceneAutoSaves()
    {
        // Only refresh if Easy Save is enabled for this scene.
        if (mgr == null || EditorApplication.isPlayingOrWillChangePlaymode)
        {
            return;
        }

        mgr.sceneObjects = new ES2AutoSave[0];
        mgr.ids          = new HashSet <string>();

        Transform[] transforms = Resources.FindObjectsOfTypeAll <Transform>();

        // Recurse over top-level scene objects and display their children hierarchically.
        foreach (Transform t in transforms)
        {
            if (t.parent == null && t.hideFlags == HideFlags.None)
            {
                ES2AutoSave autoSave = ES2AutoSave.GetAutoSave(t.gameObject);
                if (autoSave == null)
                {
                    autoSave = ES2AutoSave.AddAutoSave(t.gameObject, RandomColor(), AutoSaveComponentsAreHidden(), true, "");

                    if (AutoSaveComponentsAreHidden())
                    {
                        autoSave.hideFlags = HideFlags.HideInInspector;
                    }
                }

                // If a prefab has been added to the scene, give it an ID and treat it as a scene object.
                if (string.IsNullOrEmpty(autoSave.id))
                {
                    autoSave.id       = ES2AutoSave.GenerateID();
                    autoSave.prefabID = "";
                }

                // Check for duplicate IDs.
                if (mgr.ids.Contains(autoSave.id))
                {
                    autoSave.id = ES2AutoSave.GenerateID();
                }
                mgr.ids.Add(autoSave.id);

                UpdateAutoSave(autoSave);
                AddAutoSaveToManager(autoSave);

                GetOrAddChildrenForAutoSave(autoSave);
            }
        }
    }