コード例 #1
0
        /// <summary>
        /// 查找资源的依赖,并生成默认的分组,将依赖的资源也单独打包处理
        /// </summary>
        /// <param name="isShowProgressBar"></param>
        internal static void FindAndAddAutoGroup(bool isShowProgressBar = false)
        {
            DeleteAutoGroup();

            AssetBundleTagConfig tagConfig = Util.FileUtil.ReadFromBinary <AssetBundleTagConfig>(BundlePackUtil.GetTagConfigPath());
            AssetDependFinder    finder    = CreateAssetDependFinder(tagConfig, isShowProgressBar);

            Dictionary <string, int> repeatAssetDic = finder.GetRepeatUsedAssets();

            AssetBundleGroupData gData = new AssetBundleGroupData();

            gData.GroupName = AUTO_REPEAT_GROUP_NAME;
            gData.IsMain    = false;

            foreach (var kvp in repeatAssetDic)
            {
                AssetAddressData aaData = new AssetAddressData();
                aaData.AssetAddress = aaData.AssetPath = kvp.Key;
                aaData.BundlePath   = HashHelper.Hash_MD5_32(kvp.Key, false);//AssetDatabase.AssetPathToGUID(kvp.Key);
                gData.AssetDatas.Add(aaData);
            }

            if (gData.AssetDatas.Count > 0)
            {
                tagConfig.GroupDatas.Add(gData);
            }

            Util.FileUtil.SaveToBinary <AssetBundleTagConfig>(BundlePackUtil.GetTagConfigPath(), tagConfig);
        }
コード例 #2
0
        /// <summary>
        /// 创建资源依赖查找对象
        /// </summary>
        /// <param name="tagConfig"></param>
        /// <param name="isShowProgressBar"></param>
        /// <returns></returns>
        public static AssetDependFinder CreateAssetDependFinder(AssetBundleTagConfig tagConfig, bool isShowProgressBar = false)
        {
            AssetDependFinder finder = new AssetDependFinder();

            if (isShowProgressBar)
            {
                finder.ProgressCallback = (assetPath, progress) =>
                {
                    EditorUtility.DisplayProgressBar("Find Depend", assetPath, progress);
                };
            }

            finder.Find(tagConfig);

            if (isShowProgressBar)
            {
                EditorUtility.ClearProgressBar();
            }

            return(finder);
        }