public static void RefreshPunchDataPresetsDatabase()
        {
            EditorUtility.DisplayProgressBar("Refreshing Punch Animations Database", "", 0f);
            PunchDataPresetsDatabase = new Dictionary <string, List <PunchData> >();
            List <string> directories = new List <string>();

            directories = RemoveEmptyPresetFolders(RELATIVE_PATH_PUNCH_DATA, GetPunchPresetsDirectories);
            for (int directoryIndex = 0; directoryIndex < directories.Count; directoryIndex++)
            {
                EditorUtility.DisplayProgressBar("Refreshing Punch Animations Database", directories[directoryIndex], ((directoryIndex + 1) / (directories.Count + 2)));
                string[] fileNames = GetPunchPresetsNamesForCategory(directories[directoryIndex]);
                if (fileNames.Length == 0)
                {
                    continue;
                }                                        //empty folder
                PunchDataPresetsDatabase.Add(directories[directoryIndex], new List <PunchData>());
                for (int fileIndex = 0; fileIndex < fileNames.Length; fileIndex++)
                {
                    PunchData asset = GetResource <PunchData>(RESOURCES_PATH_PUNCH_DATA + directories[directoryIndex] + "/", fileNames[fileIndex]);
                    if (asset == null)
                    {
                        continue;
                    }
                    EditorUtility.DisplayProgressBar("Refreshing Punch Animations Database", directories[directoryIndex] + " / " + asset.presetName, ((directoryIndex + 1) / (directories.Count + 2)));
                    PunchDataPresetsDatabase[directories[directoryIndex]].Add(asset);
                }
            }
            EditorUtility.DisplayProgressBar("Refreshing Punch Animations Database", "Creating Categories List...", 0.9f);
            RefreshPunchPresetCategories();
            EditorUtility.DisplayProgressBar("Refreshing Punch Animations Database", "Validating...", 1f);
            ValidatePunchPresets();
            EditorUtility.ClearProgressBar();
        }
Beispiel #2
0
 private static PunchData CreatePunchDataAsset(string relativePath, string presetCategory, string presetName, Punch punch)
 {
     PunchData asset = ScriptableObject.CreateInstance<PunchData>();
     asset.presetName = presetName;
     asset.presetCategory = presetCategory;
     asset.data = punch;
     if (!QuickEngine.IO.File.Exists(relativePath + presetCategory + "/"))
     {
         QuickEngine.IO.File.CreateDirectory(relativePath + presetCategory + "/");
     }
     AssetDatabase.CreateAsset(asset, relativePath + presetCategory + "/" + presetName + ".asset");
     EditorUtility.SetDirty(asset);
     AssetDatabase.SaveAssets();
     AssetDatabase.Refresh();
     return asset;
 }