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("=========="); } } }
Original: https://www.cnblogs.com/sailJs/p/16587293.html
Author: yanghui01
Title: copy依赖资源到指定位置
原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/583486/
转载文章受原作者版权保护。转载请注明原作者出处!