unity编辑器部分API使用
拼接路径: string destination = Path.Combine(Application.dataPath, AssetBundleConfig.AssetsFolderName);
获取路径下文件: string[] files = Directory.GetFiles(dirPath);
获取路径下目录: string[] dirs = Directory.GetDirectories(dirPath);
设置文件的属性: File.SetAttributes(file, FileAttributes.Normal);
拷贝文件: FileUtil.CopyFileOrDirectoryFollowSymlinks(source, destination);
查找文件路径集合: Directory.GetFiles(path, "*.*", SearchOption.AllDirectories)
.Where(f => !extensions.Contains(GetFileExtension(f))).ToArray();
文件移动: File.SetAttributes(sourceFileName, FileAttributes.Normal);
File.Move(sourceFileName, destFileName);
File.Copy(sourceFiles[j], destination + "/" +Path.GetFileName(sourceFiles[j]),true);
查找资源:
var guids = AssetDatabase.FindAssets("t:AssetBundleDispatcherConfig", new string[]
{
AssetBundleInspectorUtils.DatabaseRoot });
var length = guids.Length;
var count = 0;
foreach (var guid in guids)
{
count++;
var assetPath = AssetDatabase.GUIDToAssetPath(guid);
var config = AssetDatabase.LoadAssetAtPath<AssetBundleDispatcherConfig>(assetPath);
config.Load();
EditorUtility.DisplayProgressBar("Run checker :", config.PackagePath, (float)count / length);
AssetBundleDispatcher.Run(config);
}
AssetDatabase.Refresh();
创建assets 资源:
var instance = CreateInstance<AssetBundleDispatcherConfig>();
AssetDatabase.CreateAsset(instance, databaseAssetPath);