copy依赖资源到指定位置
作者:互联网
#
using System.IO; using UnityEditor; using UnityEngine; namespace xui.Editor { public class ResDeps { [MenuItem("Assets/myTool/打印依赖", false, 99)] public static void DumpDeps() { if (null == Selection.activeObject) return; var resPath = AssetDatabase.GetAssetPath(Selection.activeObject); if (string.IsNullOrEmpty(resPath)) return; var deps = AssetDatabase.GetDependencies(resPath, true); Debug.Log("========== begin"); for (var i = 0; i < deps.Length; ++i) { Debug.Log(deps[i]); } Debug.Log("=========="); } [MenuItem("Assets/myTool/打印并copy依赖", false, 99)] public static void DumpDeps2() { if (null == Selection.activeObject) return; var resPath = AssetDatabase.GetAssetPath(Selection.activeObject); if (string.IsNullOrEmpty(resPath)) return; var deps = AssetDatabase.GetDependencies(resPath, true); Debug.Log("========== begin"); for (var i = 0; i < deps.Length; ++i) { Debug.Log(deps[i]); var dstFileFullPath = $"D:/MyConfiguration/win/Desktop/deps/{deps[i]}"; if (!File.Exists(dstFileFullPath)) { var fileFolderFullPath = Path.GetDirectoryName(dstFileFullPath); if (!Directory.Exists(fileFolderFullPath)) Directory.CreateDirectory(fileFolderFullPath); File.Copy(deps[i], dstFileFullPath); Debug.Log($"copy ->: {fileFolderFullPath}"); } var srcFileMetaPath = $"{deps[i]}.meta"; var dstFileMetaFullPath = $"{dstFileFullPath}.meta"; if (!File.Exists(dstFileMetaFullPath)) { File.Copy(srcFileMetaPath, dstFileMetaFullPath); Debug.Log($"copy meta"); } Debug.Log($"====="); } Debug.Log("=========="); } } }
标签:dstFileFullPath,依赖,Log,指定,resPath,Debug,deps,var,copy 来源: https://www.cnblogs.com/sailJs/p/16587293.html