/// <summary> [Editor Only] Adds the 'Uncategorized' database if it's missing </summary> private void AddTheDefaultUIAnimationDatabase() { if (Contains(UIAnimations.DEFAULT_DATABASE_NAME)) { return; } #if UNITY_EDITOR var asset = AssetDatabase.LoadAssetAtPath <UIAnimationDatabase>(Path.Combine(Path.Combine(DoozyPath.UIANIMATIONS_RESOURCES_PATH, DatabaseType.ToString()), UIAnimations.DEFAULT_DATABASE_NAME + ".asset")); if (asset != null) { Databases.Add(asset); UpdateDatabaseNames(); return; } UIAnimationDatabase database = AssetUtils.CreateAsset <UIAnimationDatabase>(Path.Combine(DoozyPath.UIANIMATIONS_RESOURCES_PATH, DatabaseType.ToString()), UIAnimations.DEFAULT_DATABASE_NAME); #else UIAnimationDatabase database = ScriptableObject.CreateInstance <UIAnimationDatabase>(); #endif if (database == null) { return; } database.DatabaseName = UIAnimations.DEFAULT_DATABASE_NAME; database.name = database.DatabaseName; database.DataType = DatabaseType; database.RefreshDatabase(false); Databases.Add(database); }
/// <summary> Adds a the given UIAnimationDatabase reference to the database. Returns TRUE if the operation was successful </summary> /// <param name="database"> Target UIAnimationDatabase</param> public bool AddUIAnimationDatabase(UIAnimationDatabase database) { if (database == null || database.DataType != DatabaseType || Contains(database)) { return(false); } Databases.Add(database); return(true); }
private void RemoveEmptyDatabases() { for (int i = Databases.Count - 1; i >= 0; i--) { UIAnimationDatabase database = Databases[i]; if (database != null && database.Database.Count > 0) { continue; } #if UNITY_EDITOR AssetDatabase.MoveAssetToTrash(AssetDatabase.GetAssetPath(database)); #endif Databases.RemoveAt(i); } }
/// <summary> /// Iterates through all the databases of the given database type (AnimationType) to find the one that has the given database name, then looks for the animation name. /// If found, returns a reference to the corresponding UIAnimationData, 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> /// <param name="animationName"> The animation name to search for </param> public UIAnimationData Get(AnimationType databaseType, string databaseName, string animationName) { UIAnimationDatabase category = Get(databaseType, databaseName); return(category.Get(animationName)); }
/// <summary> Returns TRUE if the UIAnimationDatabase has been found in the database </summary> /// <param name="database"> UIAnimationDatabase to search for </param> public bool Contains(UIAnimationDatabase database) { return(database != null && Databases.Contains(database)); }