static public void OnEndBuildAssetBundle(AssetBundleBuildingContext assetbundleBuildingCtx) { foreach (var behavior in BDFrameworkPipelineBehaviourInstanceList) { behavior.OnEndBuildAssetBundle(assetbundleBuildingCtx); } }
/// <summary> /// 预览结果 编辑器连线数据,但是build模式也会执行 /// 这里只建议设置BuildingCtx的ab颗粒度 /// </summary> /// <param name="target"></param> /// <param name="nodeData"></param> /// <param name="incoming"></param> /// <param name="connectionsToOutput"></param> /// <param name="outputFunc"></param> public override void Prepare(BuildTarget target, NodeData nodeData, IEnumerable <PerformGraph.AssetGroups> incoming, IEnumerable <ConnectionData> connectionsToOutput, PerformGraph.Output outputFunc) { //检测混淆 StopwatchTools.Begin(); if (BuildingCtx == null) { BuildingCtx = new AssetBundleBuildingContext(); } BuildingCtx.BuildParams.BuildTarget = target; BuildingCtx.CheckABObfuscationSource(); //设置所有节点参数请求,依次传参 Debug.Log("【初始化框架资源环境】配置:\n" + JsonMapper.ToJson(BuildingCtx.BuildParams)); var outMap = new Dictionary <string, List <AssetReference> >(); //预览模式 if ((AssetGraphWindowsModeEnum)this.AssetGraphWindowsMode == AssetGraphWindowsModeEnum.预览节点模式) { //生成buildinfo //创建构建上下文信息 GenBuildingCtx(); //输出 outMap = new Dictionary <string, List <AssetReference> >() { { nameof(FloderType.Runtime), BuildingCtx.RuntimeAssetsList.ToList() }, //传递新容器 { nameof(FloderType.Depend), BuildingCtx.DependAssetList.ToList() } }; } else if ((AssetGraphWindowsModeEnum)this.AssetGraphWindowsMode == AssetGraphWindowsModeEnum.配置节点模式) { //输出 outMap = new Dictionary <string, List <AssetReference> >() { { nameof(FloderType.Runtime), new List <AssetReference>() }, //传递新容器 { nameof(FloderType.Depend), new List <AssetReference>() } }; } StopwatchTools.End("【初始化框架资源环境】"); var output = connectionsToOutput?.FirstOrDefault(); if (output != null) { outputFunc(output, outMap); // } }
/// <summary> /// 生成BuildingCtx /// </summary> private void GenBuildingCtx(bool isRenew = false) { //新构建对象 if (isRenew) { string lastouput = BuildingCtx.BuildParams.OutputPath; BuildingCtx = new AssetBundleBuildingContext(); BuildingCtx.BuildParams.OutputPath = lastouput; } //生成build资源信息 if (BuildingCtx.BuildingAssetInfos.AssetInfoMap.Count == 0) { BuildingCtx.CollectBuildingAssets(); } }
/// <summary> /// 生成BuildingCtx /// </summary> private void GenBuildingCtx(bool isRenew = false) { Debug.Log("------------>生成BuildInfo :" + this.GetHashCode()); //新构建对象 if (isRenew) { string lastouput = BuildingCtx.BuildParams.OutputPath; BuildingCtx = new AssetBundleBuildingContext(); BuildingCtx.BuildParams.OutputPath = lastouput; } //生成build资源信息 if (BuildingCtx.BuildAssetsInfo.AssetDataMaps.Count == 0) { BuildingCtx.GenBuildInfo(); } }
/// <summary> /// 设置Params /// </summary> /// <param name="outpath"></param> /// <param name="isUseHash"></param> public void SetBuildParams(string outpath, bool isBuilding) { BuildingCtx = new AssetBundleBuildingContext(); BuildingCtx.BuildParams.OutputPath = outpath; BuildingCtx.BuildParams.IsBuilding = isBuilding; }
/// <summary> /// 一键打包时,完成导出AssetBundle /// </summary> virtual public void OnEndBuildAssetBundle(AssetBundleBuildingContext assetbundleBuildingCtx) { }
/// <summary> /// 获取AssetItem信息,这里是所有的资源 /// </summary> /// <param name="assetsRootPath"></param> /// <returns></returns> static public List <AssetItem> GetAssetItemList(string assetsRootPath, RuntimePlatform platform) { Debug.Log($"<color=red>------>生成服务器配置:{platform}</color>"); //黑名单 List <string> blackFileList = new List <string>() { BResources.EDITOR_ART_ASSET_BUILD_INFO_PATH, BResources.ASSETS_INFO_PATH, BResources.ASSETS_SUB_PACKAGE_CONFIG_PATH, string.Format("{0}/{0}", BResources.ART_ASSET_ROOT_PATH), }; //混淆文件添加黑名单 blackFileList.AddRange(AssetBundleBuildingContext.GetMixAssets()); //加载assetbundle配置 assetsRootPath = IPath.Combine(assetsRootPath, BApplication.GetPlatformPath(platform)); var abConfigPath = IPath.Combine(assetsRootPath, BResources.ART_ASSET_CONFIG_PATH); var abTypeConfigPath = IPath.Combine(assetsRootPath, BResources.ART_ASSET_TYPES_PATH); var abConfigLoader = new AssetbundleConfigLoder(); abConfigLoader.Load(abConfigPath, abTypeConfigPath); //生成hash配置 var assets = Directory.GetFiles(assetsRootPath, "*", SearchOption.AllDirectories); int ABCounter = 0; int notABCounter = 1000000; //开始生成hash var serverAssetItemList = new List <AssetItem>(); for (int i = 0; i < assets.Length; i++) { var assetPath = assets[i]; EditorUtility.DisplayProgressBar(" 获取资源hash", string.Format("生成文件hash:{0}/{1}", i, assets.Length), i / assets.Length); var ext = Path.GetExtension(assetPath).ToLower(); //无效数据 if (ext == ".manifest" || ext == ".meta") { continue; } //本地的相对路径 var localPath = assetPath.Replace("\\", "/").Replace(assetsRootPath + "/", ""); //黑名单 var ret = blackFileList.FirstOrDefault((bf) => localPath.Equals(bf, StringComparison.OrdinalIgnoreCase) || Path.GetFileName(localPath).Equals(bf)); if (ret != null) { Debug.Log("【黑名单】剔除:" + ret); continue; } //文件信息 var fileHash = FileHelper.GetMurmurHash3(assetPath); var abPath = Path.GetFileName(assetPath); var assetbundleItem = abConfigLoader.AssetbundleItemList.Find((ab) => ab.AssetBundlePath != null && ab.AssetBundlePath.Equals(abPath)); AssetItem item = null; //文件容量 var fileInfo = new FileInfo(assetPath); float fileSize = (int)((fileInfo.Length / 1024f) * 100f) / 100f; //用ab资源id添加 if (assetbundleItem != null) { if (assetbundleItem.Hash == fileHash) { ABCounter++; //这里使用ab的id,用以分包寻找资源 item = new AssetItem() { Id = assetbundleItem.Id, HashName = fileHash, LocalPath = localPath, FileSize = fileSize }; } else { Debug.LogError("【ServerAssetsItem.Info】错误! AssetBundle hash不匹配!"); } } else { notABCounter++; item = new AssetItem() { Id = notABCounter, HashName = fileHash, LocalPath = localPath, FileSize = fileSize }; } serverAssetItemList.Add(item); //放在最后,避免提前return 占用id } EditorUtility.ClearProgressBar(); //按id排序 serverAssetItemList.Sort((a, b) => { if (a.Id < b.Id) { return(-1); } else { return(1); } }); return(serverAssetItemList); }
public override void OnEndBuildAssetBundle(AssetBundleBuildingContext assetbundleBuildingCtx) { Debug.Log("实现回调测试:" + nameof(OnEndBuildAssetBundle)); }