public static bool CreateAssetFile(FileType fileType, string childPath, string fileName) { var fileNotExist = IsFileInPath(UnityPathUtility.GetUnityFullPath(childPath), fileName, fileType) == false; if (fileNotExist) { if (IsUnityFolderExist(childPath) == false) { CreateUnityFolder(childPath); } switch (fileType) { case FileType.AnimatorOverride: CreateUnityAsset(childPath, fileName, typeof(AnimatorOverrideController), GetExtension(fileType)); break; case FileType.AnimationClip: CreateUnityAsset(childPath, fileName, typeof(AnimationClip), GetExtension(fileType)); break; case FileType.Png: CreatePng(childPath, fileName); break; default: throw new ArgumentOutOfRangeException(nameof(fileType), fileType, null); } RefreshAsset(); } return(fileNotExist); }
public static void CreateUnityAsset(string childPath, string fileName, Type type, string extension) { var instance = (Object)Activator.CreateInstance(type); var path = UnityPathUtility.GetUnityFullPath(childPath, fileName, extension); AssetDatabase.CreateAsset(instance, path); RefreshAsset(); }