diff --git a/Assets/Aster/EditorUtils/EditorUtils.cs b/Assets/Aster/EditorUtils/EditorUtils.cs index 7feb4f564268d15ecb6595d0b8c4e37a1390ba67..61ce06435291e8d9e393714380545c0203fbdb96 100644 --- a/Assets/Aster/EditorUtils/EditorUtils.cs +++ b/Assets/Aster/EditorUtils/EditorUtils.cs @@ -195,6 +195,44 @@ namespace Aster.AsterBinary #endif } + /// + /// 同时创建大批量文件; + /// + /// + /// + /// + /// + public static T[] CreateAssets(T[] objs, string[] newPath) where T : Object + { +#if UNITY_EDITOR + if (objs == null) + return null; + int length = objs.Length; + T[] result = new T[length]; + + AssetDatabase.StartAssetEditing(); + + try + { + for (int i = 0; i < length; i++) + { + var obj = objs[i]; + var path = newPath[i]; + result[i] = CreateAsset(obj, path); + } + } + catch (System.Exception ex) + { + Logger.LogException(ex); + } + + AssetDatabase.StopAssetEditing(); + return result; +#else + return null; +#endif + } + public static void SaveAndRefresh() { #if UNITY_EDITOR