private static void GetChildrenForAutoSave(ES2AutoSave autoSave) { foreach (Transform t in autoSave.transform) { ES2AutoSave child = ES2AutoSave.GetAutoSave(t.gameObject); if (child == null) { child = ES2AutoSave.AddAutoSave(t.gameObject, RandomColor(), AutoSaveComponentsAreHidden(), true, ""); } GetChildrenForAutoSave(child); } }
/* * 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); } } }
protected void GetColumnsForAutoSave(ES2AutoSave autoSave, int hierarchyDepth) { ES2EditorColumn column = GetColumn(0); ES2EditorRow row = column.AddRow(autoSave.gameObject.name, autoSave, ES2EditorWindow.instance.style.saveButtonStyle, ES2EditorWindow.instance.style.saveButtonSelectedStyle, hierarchyDepth); if (autoSave.selected) { if (autoSave.selectionChanged) { ES2EditorAutoSaveUtility.UpdateAutoSave(autoSave); } GetComponentsColumnForAutoSave(autoSave, column, row); } if (autoSave.buttonSelected && autoSave.buttonSelectionChanged) { // Add support for any Components which are currently unsupported. Component[] components = autoSave.GetComponents <Component>(); foreach (Component c in components) { // Handle unassigned components. if (c == null) { continue; } // If this Component isn't currently supported, add support for it and isn't an ES2AutoSave. if (!ES2EditorTypeUtility.TypeIsSupported(c.GetType()) && !typeof(ES2AutoSave).IsAssignableFrom(c.GetType()) && !typeof(ES2AutoSaveManager).IsAssignableFrom(c.GetType())) { ES2EditorTypeUtility.AddType(c.GetType()); } } } foreach (Transform t in autoSave.transform) { ES2AutoSave child = ES2AutoSave.GetAutoSave(t.gameObject); if (child != null) { GetColumnsForAutoSave(child, hierarchyDepth + 1); } } }
private static void GetOrAddChildrenForAutoSave(ES2AutoSave autoSave) { if (autoSave == null) { return; } foreach (Transform t in autoSave.transform) { ES2AutoSave child = ES2AutoSave.GetAutoSave(t.gameObject); if (child == null) { child = ES2AutoSave.AddAutoSave(t.gameObject, RandomColor(), AutoSaveComponentsAreHidden(), true, ""); } UpdateAutoSave(child); AddAutoSaveToManager(child); GetOrAddChildrenForAutoSave(child); } }