void UpdateIDsForPack(AssetObjectPack pack) { string[] pathsWithoutIDs = EditorUtils.GetFilePathsInDirectory(pack.dir, true, pack.extensions, AssetObjectsEditor.sIDKey, false); if (pathsWithoutIDs.Length == 0) { Debug.Log("All assets in " + pack.name + " objects directory have IDs"); return; } GenerateNewIDs(AssetObjectsEditor.GetAllAssetObjectPaths(pack.dir, pack.extensions, false), pathsWithoutIDs); }
void GenerateNewIDs(string[] validPaths, string[] noIDs) { int l = noIDs.Length; int[] newIDs = GenerateNewIDList(l, validPaths.Length.Generate(i => AssetObjectsEditor.GetObjectIDFromPath(validPaths[i])).ToHashSet()); for (int i = 0; i < l; i++) { string path = noIDs[i]; if (path.Contains(AssetObjectsEditor.sIDKey)) { Debug.LogWarning("asset was already assigned an id: " + path); continue; } AssetDatabase.RenameAsset(path, AssetObjectsEditor.sIDKey + newIDs[i] + "-" + EditorUtils.RemoveDirectory(path)); } Debug.Log("Assets are now ready with unique IDs"); }