Пример #1
0
        static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths)
        {
            foreach (string asset_path in importedAssets)
            {
                string file_name = Path.GetFileName(asset_path);
                if (file_name == "_ASSET_BUNDLE_.txt")
                {
                    CDebugOut.Log(asset_path + "变更了");
                    CAssetBundleEditor.CreateResourcePath();
                    return;
                }
            }

            foreach (string asset_path in deletedAssets)
            {
                string file_name = Path.GetFileName(asset_path);
                if (file_name == "_ASSET_BUNDLE_.txt")
                {
                    CDebugOut.Log(asset_path + "删除了");
                    CAssetBundleEditor.CreateResourcePath();
                    return;
                }
            }

            foreach (string asset_path in movedAssets)
            {
                string file_name = Path.GetFileName(asset_path);
                if (file_name == "_ASSET_BUNDLE_.txt")
                {
                    CDebugOut.Log(asset_path + "移动了");
                    CAssetBundleEditor.CreateResourcePath();
                    return;
                }
            }

            foreach (string asset_path in movedFromAssetPaths)
            {
                string file_name = Path.GetFileName(asset_path);
                if (file_name == "_ASSET_BUNDLE_.txt")
                {
                    CDebugOut.Log(asset_path + "路径变更了");
                    CAssetBundleEditor.CreateResourcePath();
                    return;
                }
            }
        }
Пример #2
0
        //查找引用关系
        public static void Find(string assetPath)
        {
            if (string.IsNullOrEmpty(assetPath))
            {
                CDebugOut.LogError("assetPath is null or empty!");
                return;
            }

            string[] dependencies = AssetDatabase.GetDependencies(assetPath, false);

            if (referenceCache.ContainsKey(assetPath) == false)
            {
                referenceCache[assetPath] = new List <string>()
                {
                }
            }
            ;

            foreach (var dependency in dependencies)
            {
                if (referenceCache.ContainsKey(dependency))
                {
                    if (!referenceCache[dependency].Contains(assetPath))
                    {
                        referenceCache[dependency].Add(assetPath);
                    }
                }
                else
                {
                    referenceCache[dependency] = new List <string>()
                    {
                        assetPath
                    };
                }
            }
        }