/* * Refreshes the variables and Components for all Auto Saves attached to prefabs. * Should be called after scripts are recompiled. */ public static void RefreshPrefabAutoSaves() { ES2AutoSaveGlobalManager globalMgr = ES2EditorAutoSaveUtility.globalMgr; if (globalMgr == null) { return; } // Clear all prefabs and start from fresh. globalMgr.prefabArray = new ES2AutoSave[0]; globalMgr.ids = new HashSet <string>(); List <GameObject> prefabs = GetPrefabs(); for (int i = 0; i < prefabs.Count; i++) { if (prefabs[i] == null) { continue; } ES2AutoSave autoSave = prefabs[i].GetComponent <ES2AutoSave>(); if (autoSave != null) { ArrayUtility.Add(ref globalMgr.prefabArray, autoSave); } } // Recurse over top-level scene objects, and recursively update them and their children. foreach (ES2AutoSave autoSave in globalMgr.prefabArray) { UpdatePrefabAutoSaveRecursive(autoSave); } }
public override object Read(ES2Reader reader) { ES2AutoSaveGlobalManager data = GetOrCreate <ES2AutoSaveGlobalManager>(); Read(reader, data); return(data); }
public override void Write(object obj, ES2Writer writer) { ES2AutoSaveGlobalManager data = (ES2AutoSaveGlobalManager)obj; // Add your writer.Write calls here. writer.Write(data.useGUILayout); writer.Write(data.runInEditMode); writer.Write(data.enabled); writer.Write(data.hideFlags); }
public override void Read(ES2Reader reader, object c) { ES2AutoSaveGlobalManager data = (ES2AutoSaveGlobalManager)c; // Add your reader.Read calls here to read the data into the object. data.useGUILayout = reader.Read <System.Boolean>(); data.runInEditMode = reader.Read <System.Boolean>(); data.enabled = reader.Read <System.Boolean>(); data.hideFlags = reader.Read <UnityEngine.HideFlags>(); }
// Enable Auto Save for a prefab and it's children. public static void EnableAutoSaveForSelectedPrefabRecursive(GameObject prefab) { ES2AutoSave autoSave = prefab.GetComponent <ES2AutoSave>(); // Only add an Auto Save if this prefab doesn't already have one. if (autoSave == null) { // Add an ES2AutoSave to the prefab and add it to the Auto Save manager prefab. autoSave = ES2AutoSave.AddAutoSave(prefab, RandomColor(), AutoSaveComponentsAreHidden(), false, ""); ES2AutoSaveGlobalManager globalManager = globalMgr; // Don't add prefab to prefab array if it's a child prefab. if (autoSave.transform.parent == null) { ArrayUtility.Add(ref globalManager.prefabArray, autoSave); } } foreach (Transform childTransform in prefab.transform) { EnableAutoSaveForSelectedPrefabRecursive(childTransform.gameObject); } }