/// <summary> [Editor Only] Performs a deep search through the project for any unregistered UIAnimationDatabase asset files and adds them to the corresponding Database </summary> /// <param name="saveAssets"> Write all unsaved asset changes to disk? </param> public void SearchForUnregisteredDatabases(bool saveAssets) { DoozyUtils.DisplayProgressBar("UIAnimations", "Initializing", 0.1f); Initialize(); DoozyUtils.DisplayProgressBar("UIAnimations", "Searching for databases", 0.3f); bool foundUnregisteredDatabase = false; UIAnimationDatabase[] array = Resources.LoadAll <UIAnimationDatabase>(""); if (array == null || array.Length == 0) { DoozyUtils.ClearProgressBar(); return; } DoozyUtils.DisplayProgressBar("UIAnimations", "Updating databases", 0.5f); foreach (UIAnimationDatabase foundDatabase in array) { UIAnimationsDatabase database = Get(foundDatabase.DataType); if (database == null) { continue; } if (database.Contains(foundDatabase)) { continue; } database.AddUIAnimationDatabase(foundDatabase); foundUnregisteredDatabase = true; } if (!foundUnregisteredDatabase) { DoozyUtils.ClearProgressBar(); return; } DoozyUtils.DisplayProgressBar("UIAnimations", "Update Show", 0.6f); Show.Update(); DoozyUtils.DisplayProgressBar("UIAnimations", "Update Hide", 0.6f); Hide.Update(); DoozyUtils.DisplayProgressBar("UIAnimations", "Update Loop", 0.7f); Loop.Update(); DoozyUtils.DisplayProgressBar("UIAnimations", "Update Punch", 0.8f); Punch.Update(); DoozyUtils.DisplayProgressBar("UIAnimations", "Update State", 0.9f); State.Update(); DoozyUtils.DisplayProgressBar("UIAnimations", "Saving database", 1f); SetDirty(saveAssets); DoozyUtils.ClearProgressBar(); }
/// <summary> /// Performs an initial check to make sure that all the UIAnimation.Database references are not null (if they are, it generates the missing ones). /// After the references have been validated, the databases are updated. /// </summary> public void Initialize() { bool needsSave = false; if (Show == null) { Show = new UIAnimationsDatabase(AnimationType.Show); needsSave = true; } if (Show.DatabaseType != AnimationType.Show) { Show.DatabaseType = AnimationType.Show; needsSave = true; } if (Hide == null) { Hide = new UIAnimationsDatabase(AnimationType.Hide); needsSave = true; } if (Hide.DatabaseType != AnimationType.Hide) { Hide.DatabaseType = AnimationType.Hide; needsSave = true; } if (Loop == null) { Loop = new UIAnimationsDatabase(AnimationType.Loop); needsSave = true; } if (Loop.DatabaseType != AnimationType.Loop) { Loop.DatabaseType = AnimationType.Loop; needsSave = true; } if (Punch == null) { Punch = new UIAnimationsDatabase(AnimationType.Punch); needsSave = true; } if (Punch.DatabaseType != AnimationType.Punch) { Punch.DatabaseType = AnimationType.Punch; needsSave = true; } if (State == null) { State = new UIAnimationsDatabase(AnimationType.State); needsSave = true; } if (State.DatabaseType != AnimationType.State) { State.DatabaseType = AnimationType.State; needsSave = true; } Show.Update(); Hide.Update(); Loop.Update(); Punch.Update(); State.Update(); if (needsSave) { SetDirty(true); } }
/// <summary> /// Iterates through all the databases of the given database type (AnimationType) to find the one that has the given database name. /// If found, returns a reference to the corresponding UIAnimationDatabase, else it returns null. /// </summary> /// <param name="databaseType"> The type of animations contained in the target database </param> /// <param name="databaseName"> The database name to search for </param> public UIAnimationDatabase Get(AnimationType databaseType, string databaseName) { UIAnimationsDatabase database = Get(databaseType); return(database.Get(databaseName)); }