static void TotalClear() { var bcConfig = BundlesConfig.GetInstance(); if (bcConfig != null) { bcConfig.Clear(); } var map = BundlesMap.GetInstance(); if (map != null) { map.Clear(); } var info = BundlesResult.GetInstance(); if (info != null) { info.Clear(); } UtilsAsset.AssetsRefresh(); }
/// <summary> /// 更新本地信息,为下一步下载做准备. /// </summary> public void UpdateLocalInfoForDownload() { // bundles目录 string bundlesDir = ServersConf.BundlesDir; // 导入Bundle包依赖关系 BundlesMap.GetInstance().ImportFromJsonFile(bundlesDir, true); // 导入已经有下载信息 DownloadList.GetInstance().ImportFromJsonFile(bundlesDir, true); // 将已经下载的最新依赖列表文件更新本地依赖列表 string downloadDir = ServersConf.DownloadDir; // 不清空本地 BundlesMap.GetInstance().ImportFromJsonFile(downloadDir, false); // 从最新的上传列表更新下载信息 // 抽出条件 // 1)上传完毕 // 2)没有被废弃 UploadItem[] targets = this.Targets .Where(o => ( (false == o.Scraped))) .OrderBy(o => o.No) .ToArray(); if ((targets == null) || (targets.Length <= 0)) { this.Info("UpdateLocalInfoForDownload()::There is no target to download!!!"); return; } this.Info("UpdateLocalInfoForDownload()::Targets Count:{0}", targets.Length.ToString()); foreach (UploadItem Loop in targets) { DownloadList.GetInstance().AddTarget(Loop); } // 初始化进度计数器 DownloadList.GetInstance().InitProgressCounter(); }
/// <summary> /// 下载完成确认. /// </summary> /// <param name="iIsDidDownloaded">是否下载过.</param> private void DownloadCompleteNotification(bool iIsDidDownloaded) { if ((this._downloadEvents != null) && (this._downloadEvents.OnCompletedNotification != null)) { this._downloadEvents.OnCompletedNotification.Invoke(); } this._isCompleted = true; if (iIsDidDownloaded == true) { // 取得导出目录 string ExportDir = ServersConf.BundlesDir; // 导出最新的下载列表信息 DownloadList.GetInstance().ExportToJsonFile(ExportDir); // 导入Bundle包依赖关系 BundlesMap.GetInstance().ExportToJsonFile(ExportDir); // 清空下载文件夹 this.ClearDownloadDir(); } }
/// <summary> /// 上传Bundle包依赖文件. /// </summary> /// <param name="iServerInfo">服务器信息.</param> private string UploadBundlesMapFile(UploadServerInfo iServerInfo) { // 导出文件 string inputFilePath = BundlesMap.GetInstance().ExportToJsonFile(); UtilsLog.Info("UploadBundlesMapFile", "ExportToJsonFile(Path:{0})", inputFilePath); // 上传URL string uploadUrl = ServersConf.GetUploadListBaseUrl(iServerInfo); if (File.Exists(inputFilePath) == true) { int lastIndex = inputFilePath.LastIndexOf("/"); string fileName = inputFilePath.Substring(lastIndex + 1); uploadUrl = string.Format("{0}/{1}", uploadUrl, fileName); // 上传Bundles列表信息文件 this._State = UpLoadFileToFtpServer( uploadUrl, inputFilePath, iServerInfo.AccountId, iServerInfo.Pwd); if (TRunState.OK != this._State) { UtilsLog.Error("UploadBundlesMapFile", "Upload Failed!!! \n {0} -> {1}", inputFilePath, uploadUrl); return(null); } else { this._uploadState = string.Format("[Upload] {0}", fileName); return(inputFilePath); } } else { UtilsLog.Error("UploadBundlesMapFile", "Upload Failed!!! \n Upload file is not exist!!!(Path:{0})", inputFilePath); return(null); } }
/// <summary> /// 打包资源文件 /// </summary> /// <param name="buildTarget">Build target.</param> /// <param name="needCompress">If set to <c>true</c> need compress.</param> private static void BuildAssetBundle(BuildTarget buildTarget, bool needCompress = false) { const string funcBlock = "AssetBundlesBuild.BuildAssetBundle()"; BuildLogger.OpenBlock(funcBlock); // 设置上传的打包类型 UploadList.GetInstance().BuildTarget = buildTarget.ToString(); BundlesConfig bcConfig = BundlesConfig.GetInstance(); if ((null == bcConfig) || (0 >= bcConfig.Resources.Count)) { BuildLogger.LogError("BuildAssetBundle::BundlesConfig is invalid!!!"); return; } // 清空依赖关系列表 BundlesMap bundlesMap = BundlesMap.GetInstance(); if (null == bundlesMap) { BuildLogger.LogError("BuildAssetBundle::bundlesMap is invalid!!!"); return; } bundlesMap.Clear(); List <BundleResource> allConfig = bcConfig.Resources; // make bundle config foreach (BundleResource bc in allConfig) { // filter file if (bc.Mode == BundleMode.OneDir) { string bundleId = BundlesMap.GetBundleID(bc.Path); BundleMap bm = bundlesMap.GetOrCreateBundlesMap(bundleId); bm.ID = bundleId; bm.Path = bc.Path; // 取得当前目录的文件列表 List <string> files = GetAllFiles(bc.Path); // 遍历文件列表 foreach (string file in files) { // .DS_Store文件 if (file.EndsWith(".DS_Store") == true) { continue; } // *.meta文件 if (file.EndsWith(".meta") == true) { continue; } // 若为忽略文件,则跳过 if (bcConfig.isIgnoreFile(bc, file) == true) { bm.RemoveIgnorFile(file); continue; } bm.AddFile(file); } bundlesMap.Maps.Add(bm); } else if (bc.Mode == BundleMode.SceneOneToOne) { // 取得当前目录的文件列表 List <string> files = GetAllFiles(bc.Path); foreach (string file in files) { // .DS_Store文件 if (file.EndsWith(".DS_Store") == true) { continue; } // *.meta文件 if (file.EndsWith(".meta") == true) { continue; } // 若非场景文件,则跳过 if (file.EndsWith(".unity") == false) { continue; } // 若为忽略文件,则跳过 string bundleId = BundlesMap.GetBundleID(file); BundleMap bm = bundlesMap.GetOrCreateBundlesMap(bundleId); if (bcConfig.isIgnoreFile(bc, file) == true) { bm.RemoveIgnorFile(file); continue; } bm.ID = bundleId; bm.Path = bc.Path; bm.Type = TBundleType.Scene; bm.AddFile(file); bundlesMap.Maps.Add(bm); } } else if (bc.Mode == BundleMode.FileOneToOne) { // 取得当前目录的文件列表 List <string> files = GetAllFiles(bc.Path); foreach (string file in files) { // .DS_Store文件 if (file.EndsWith(".DS_Store") == true) { continue; } // *.meta文件 if (file.EndsWith(".meta") == true) { continue; } // 若为忽略文件,则跳过 string bundleId = BundlesMap.GetBundleID(file); BundleMap bm = bundlesMap.GetOrCreateBundlesMap(bundleId); if (bcConfig.isIgnoreFile(bc, file) == true) { bm.RemoveIgnorFile(file); continue; } bm.ID = bundleId; bm.Path = bc.Path; bm.AddFile(file); bundlesMap.Maps.Add(bm); } } else if (bc.Mode == BundleMode.TopDirOneToOne) { // 取得目录列表 string[] directories = Directory.GetDirectories(bc.Path); if ((directories == null) || (directories.Length <= 0)) { BuildLogger.LogWarning("The no subfolder in this path!!!(dir:{0})", bc.Path); continue; } foreach (string dir in directories) { // 取得当前目录的文件列表 List <string> files = GetAllFiles(dir); string bundleId = BundlesMap.GetBundleID(dir); bundleId = BundlesMap.GetBundleID(dir); if (string.IsNullOrEmpty(bundleId) == true) { continue; } BundleMap bm = bundlesMap.GetOrCreateBundlesMap(bundleId); bm.ID = bundleId; bm.Path = bc.Path; foreach (string file in files) { // .DS_Store文件 if (file.EndsWith(".DS_Store") == true) { continue; } // *.meta文件 if (file.EndsWith(".meta") == true) { continue; } // 若为忽略文件,则跳过 if (bcConfig.isIgnoreFile(bc, file) == true) { bm.RemoveIgnorFile(file); continue; } bm.AddFile(file); } bundlesMap.Maps.Add(bm); } } } // 目录检测 string checkDir = UploadList.GetInstance().BundlesOutputDir; if (Directory.Exists(checkDir) == false) { Directory.CreateDirectory(checkDir); } checkDir = UploadList.GetInstance().BundlesOutputDirOfNormal; if (Directory.Exists(checkDir) == false) { Directory.CreateDirectory(checkDir); } checkDir = UploadList.GetInstance().BundlesOutputDirOfScene; if (Directory.Exists(checkDir) == false) { Directory.CreateDirectory(checkDir); } bool successed = false; AssetBundleManifest result = null; string[] allAssets = null; AssetBundleBuild[] targets = null; // 一般Bundles try { targets = bundlesMap.GetAllNormalBundleTargets(); BuildAssetBundleOptions options = BuildAssetBundleOptions.UncompressedAssetBundle; result = BuildPipeline.BuildAssetBundles( UploadList.GetInstance().BundlesOutputDirOfNormal, targets, options, buildTarget); BuildLogger.LogMessage(" -> BuildPipeline.BuildAssetBundles"); if (result != null) { allAssets = result.GetAllAssetBundles(); if ((allAssets != null) && (targets.Length == allAssets.Length)) { successed = true; } } } catch (Exception exp) { BuildLogger.LogException("BuildAssetBundles Detail : {0}", exp.Message); successed = false; } // 更新导出标志位 if (successed == true) { BuildLogger.LogMessage(" -> BundlesConfig.UpdateBundleStateWhenCompleted"); Dictionary <string, string> hashCodes = new Dictionary <string, string>(); foreach (string asset in allAssets) { Hash128 hashCode = result.GetAssetBundleHash(asset); if (string.IsNullOrEmpty(hashCode.ToString()) == true) { continue; } string fileSuffix = UploadList.GetInstance().FileSuffix; string key = asset; if (string.IsNullOrEmpty(fileSuffix) == false) { fileSuffix = fileSuffix.ToLower(); fileSuffix = string.Format(".{0}", fileSuffix); key = key.Replace(fileSuffix, ""); } hashCodes[key] = hashCode.ToString(); } // 初始化检测信息(Hash Code) bundlesMap.UpdateUploadList(TBundleType.Normal, hashCodes); BuildLogger.LogMessage(" -> BundlesMap.UpdateUploadList Normal"); } // Scene Bundles List <SceneBundleInfo> targetScenes = bundlesMap.GetAllSceneBundleTargets(); if ((targetScenes != null) && (targetScenes.Count > 0)) { foreach (SceneBundleInfo scene in targetScenes) { if ((scene == null) || (scene.GetAllTargets() == null) || (scene.GetAllTargets().Length <= 0)) { continue; } try { BuildOptions options = BuildOptions.BuildAdditionalStreamedScenes; if (TBuildMode.Debug == BuildInfo.GetInstance().BuildMode) { options |= BuildOptions.Development; } string sceneState = BuildPipeline.BuildPlayer( scene.GetAllTargets(), UploadList.GetLocalSceneBundleFilePath(scene.BundleId), buildTarget, options); BuildLogger.LogMessage(" -> BuildPipeline.BuildStreamedSceneAssetBundle(State:{0})", sceneState); } catch (Exception exp) { BuildLogger.LogException("BuildStreamedSceneAssetBundle Detail:{0}", exp.Message); successed = false; } } } // 更新导出标志位 if (successed == true) { BuildLogger.LogMessage(" -> BundlesConfig.UpdateBundleStateWhenCompleted"); // 初始化检测信息(Hash Code) bundlesMap.UpdateUploadList(TBundleType.Scene); BuildLogger.LogMessage(" -> BundlesMap.UpdateUploadList Scene"); } BuildInfo.GetInstance().ExportToJsonFile(); BuildLogger.LogMessage(" -> BuildInfo.ExportToJsonFile"); BuildLogger.CloseBlock(); }
static void CreateUploadShell() { const string funcBlock = "AssetBundlesBuild.CreateUploadShell()"; BuildLogger.OpenBlock(funcBlock); string filePath = string.Format("{0}/../Shell/Upload.sh", Application.dataPath); if (File.Exists(filePath) == true) { File.Delete(filePath); } FileStream fs = new FileStream(filePath, FileMode.OpenOrCreate, FileAccess.Write); if (null == fs) { return; } StreamWriter sw = new StreamWriter(fs); if (null == sw) { if (null != fs) { fs.Flush(); fs.Close(); fs.Dispose(); } return; } // 写入文件头 sw.WriteLine("#!/bin/bash"); sw.Flush(); sw.WriteLine(""); sw.Flush(); // 设定变量 sw.WriteLine("# 上传根目录"); sw.WriteLine("ROOT_DIR=bundles"); sw.Flush(); sw.WriteLine("# 本地上传路径"); sw.WriteLine(string.Format("UPLOAD_FROM_ROOT_DIR={0}/StreamingAssets", Application.dataPath)); sw.WriteLine(""); sw.Flush(); sw.WriteLine("# 上传目标平台"); sw.WriteLine(string.Format("BUILD_TARGET={0}", UploadList.GetInstance().BuildTarget)); sw.Flush(); sw.WriteLine("# App Version"); sw.WriteLine(string.Format("APP_VERSION={0}", UploadList.GetInstance().AppVersion)); sw.Flush(); sw.WriteLine("# Center Version"); sw.WriteLine(string.Format("CENTER_VERSION={0}", UploadList.GetInstance().CenterVersion)); sw.WriteLine(""); sw.Flush(); UploadServerInfo uploadServer = ServersConf.GetInstance().UploadServer; sw.WriteLine("# 检测上传目录"); sw.WriteLine("# $1 上传目录"); sw.WriteLine("checkUploadDir()"); sw.WriteLine("{"); sw.WriteLine("ftp -n<<!"); sw.WriteLine(string.Format("open {0} {1}", uploadServer.IpAddresss, uploadServer.PortNo)); sw.WriteLine(string.Format("user {0} {1}", uploadServer.AccountId, uploadServer.Pwd)); sw.WriteLine("binary"); sw.WriteLine("pwd"); sw.WriteLine("if [ ! -d \"$1\" ]; then"); sw.WriteLine(" mkdir \"$1\""); sw.WriteLine("fi"); sw.WriteLine("prompt"); // sw.WriteLine("ls -l"); sw.WriteLine("close"); sw.WriteLine("bye"); sw.WriteLine("!"); sw.WriteLine("}"); sw.WriteLine(""); sw.Flush(); sw.WriteLine("# 文件上传函数"); sw.WriteLine("# $1 本地上传目录"); sw.WriteLine("# $2 上传目标目录"); sw.WriteLine("# $3 上传目标文件"); sw.WriteLine("upload()"); sw.WriteLine("{"); sw.WriteLine("ftp -n<<!"); sw.WriteLine(string.Format("open {0} {1}", uploadServer.IpAddresss, uploadServer.PortNo)); sw.WriteLine(string.Format("user {0} {1}", uploadServer.AccountId, uploadServer.Pwd)); sw.WriteLine("binary"); sw.WriteLine("cd \"$2\""); sw.WriteLine("lcd \"$1\""); sw.WriteLine("pwd"); sw.WriteLine("prompt"); sw.WriteLine("put \"$3\""); // sw.WriteLine("ls -l"); sw.WriteLine("close"); sw.WriteLine("bye"); sw.WriteLine("!"); sw.WriteLine("}"); sw.WriteLine(""); sw.Flush(); sw.WriteLine("# 检测目录"); sw.WriteLine("checkUploadDir $ROOT_DIR"); sw.WriteLine("checkUploadDir $ROOT_DIR/$BUILD_TARGET"); sw.WriteLine("checkUploadDir $ROOT_DIR/$BUILD_TARGET/$APP_VERSION"); sw.WriteLine(""); sw.Flush(); sw.WriteLine("# 上传资源文件"); List <UploadItem> Targets = UploadList.GetInstance().Targets; UploadItem[] _normals = Targets .Where(o => (TBundleType.Normal == o.BundleType)) .OrderBy(o => o.No) .ToArray(); if (0 < _normals.Length) { sw.WriteLine("# 检测一般文件目录"); sw.WriteLine(string.Format("checkUploadDir $ROOT_DIR/$BUILD_TARGET/$APP_VERSION/{0}", TBundleType.Normal.ToString())); sw.WriteLine("# 一般文件"); foreach (UploadItem loop in _normals) { string fileName = UploadList.GetLocalBundleFileName(loop.ID, loop.FileType); sw.WriteLine(string.Format("upload $UPLOAD_FROM_ROOT_DIR/{0} $ROOT_DIR/$BUILD_TARGET/$APP_VERSION/{0} {1}", TBundleType.Normal.ToString(), fileName)); } sw.WriteLine(""); sw.Flush(); } UploadItem[] _scenes = Targets .Where(o => (TBundleType.Scene == o.BundleType)) .OrderBy(o => o.No) .ToArray(); if (0 < _scenes.Length) { sw.WriteLine("# 检测场景文件目录"); sw.WriteLine(string.Format("checkUploadDir $ROOT_DIR/$BUILD_TARGET/$APP_VERSION/{0}", TBundleType.Scene.ToString())); sw.WriteLine("# 场景文件"); foreach (UploadItem loop in _scenes) { string fileName = UploadList.GetLocalBundleFileName(loop.ID, loop.FileType); sw.WriteLine(string.Format("upload $UPLOAD_FROM_ROOT_DIR/{0} $ROOT_DIR/$BUILD_TARGET/$APP_VERSION/{0} {1}", TBundleType.Scene.ToString(), fileName)); } sw.WriteLine(""); sw.Flush(); } // 导出依赖文件 BundlesMap.GetInstance().ExportToJsonFile(string.Format("{0}/StreamingAssets", Application.dataPath)); sw.WriteLine("# 上传依赖文件"); sw.WriteLine("upload $UPLOAD_FROM_ROOT_DIR $ROOT_DIR/$BUILD_TARGET/$APP_VERSION BundlesMapData.json"); // 导出上传列表文件 UploadList.GetInstance().ExportToJsonFile(string.Format("{0}/StreamingAssets", Application.dataPath)); sw.WriteLine("# 上传上传列表文件"); sw.WriteLine("upload $UPLOAD_FROM_ROOT_DIR $ROOT_DIR/$BUILD_TARGET/$APP_VERSION UploadListData.json"); if (0 < Targets.Count) { sw.WriteLine("# 清空上传文件"); sw.WriteLine(string.Format("rm -rfv $UPLOAD_FROM_ROOT_DIR", TBundleType.Normal.ToString())); sw.WriteLine(""); sw.Flush(); } sw.WriteLine(""); sw.Flush(); if (null != fs) { fs.Flush(); fs.Close(); fs.Dispose(); } if (null != sw) { sw.Flush(); sw.Close(); sw.Dispose(); } BuildLogger.CloseBlock(); }
/// <summary> /// 打包资源文件 /// </summary> /// <param name="iBuildTarget">打包目标.</param> /// <param name="iNeedCompress">压缩标识位.</param> private static void BuildAssetBundle(BuildTarget iBuildTarget, bool iNeedCompress = false) { const string funcBlock = "AssetBundlesBuild:BuildAssetBundle()"; Loger.BuildStart(funcBlock); Loger.BuildLog($"BuildTarget:{iBuildTarget} NeedCompress:{iNeedCompress}"); // 清空上传信息 BundlesResult.GetInstance().Clear(); // 打包名 BundlesResult.GetInstance().BuildName = SysSettings.GetInstance().BuildName; // 打包名 BundlesResult.GetInstance().AppVersion = SysSettings.GetInstance().BuildVersion; // 打包名 BundlesResult.GetInstance().CheckMode = CheckMode.CustomMd5; // 设置上传的打包类型 BundlesResult.GetInstance().BuildTarget = iBuildTarget.ToString(); var bcConfig = BundlesConfig.GetInstance(); if (null == bcConfig || 0 >= bcConfig.Resources.Count) { Loger.BuildErrorLog("BundlesConfig is invalid!!!"); return; } // 清空依赖关系列表 var bundlesMap = BundlesMap.GetInstance(); if (null == bundlesMap) { Loger.BuildErrorLog("BundlesMap is invalid!!!"); return; } bundlesMap.Clear(); var allConfig = bcConfig.Resources; // make bundle config foreach (var bc in allConfig) { switch (bc.mode) { // filter file case BundleMode.OneDir: { var bundleId = BundlesMap.GetBundleId(bc.path); var bm = BundlesMap.GetOrCreateBundlesMap(bundleId); bm.id = bundleId; bm.path = bc.path; // 取得当前目录的文件列表 var files = GetAllFiles(bc.path); // 遍历文件列表 foreach (var file in files) { // .DS_Store文件 if (file.EndsWith(".DS_Store")) { continue; } // *.meta文件 if (file.EndsWith(".meta")) { continue; } // 若为忽略文件,则跳过 if (bcConfig.IsIgnoreFile(bc, file)) { bm.RemoveIgnorFile(file); continue; } bm.AddFile(file); } bundlesMap.Maps.Add(bm); break; } case BundleMode.SceneOneToOne: { // 取得当前目录的文件列表 var files = GetAllFiles(bc.path); foreach (var file in files) { // .DS_Store文件 if (file.EndsWith(".DS_Store")) { continue; } // *.meta文件 if (file.EndsWith(".meta")) { continue; } // 若非场景文件,则跳过 if (file.EndsWith(".unity") == false) { continue; } // 若为忽略文件,则跳过 var bundleId = BundlesMap.GetBundleId(file); var bm = BundlesMap.GetOrCreateBundlesMap(bundleId); if (bcConfig.IsIgnoreFile(bc, file)) { bm.RemoveIgnorFile(file); continue; } bm.id = bundleId; bm.path = bc.path; bm.type = BundleType.Scene; bm.AddFile(file); bundlesMap.Maps.Add(bm); } break; } case BundleMode.FileOneToOne: { // 取得当前目录的文件列表 var files = GetAllFiles(bc.path); foreach (var file in files) { // .DS_Store文件 if (file.EndsWith(".DS_Store")) { continue; } // *.meta文件 if (file.EndsWith(".meta")) { continue; } // 若为忽略文件,则跳过 var bundleId = BundlesMap.GetBundleId(file); var bm = BundlesMap.GetOrCreateBundlesMap(bundleId); if (bcConfig.IsIgnoreFile(bc, file)) { bm.RemoveIgnorFile(file); continue; } bm.id = bundleId; bm.path = bc.path; bm.AddFile(file); bundlesMap.Maps.Add(bm); } break; } case BundleMode.TopDirOneToOne: { // 取得目录列表 var directories = Directory.GetDirectories(bc.path); if (directories.Length <= 0) { Loger.BuildWarningLog($"The no subfolder in this path!!!(dir:{bc.path})"); continue; } foreach (var dir in directories) { // 取得当前目录的文件列表 var files = GetAllFiles(dir); var bundleId = BundlesMap.GetBundleId(dir); if (string.IsNullOrEmpty(bundleId)) { continue; } var bm = BundlesMap.GetOrCreateBundlesMap(bundleId); bm.id = bundleId; bm.path = bc.path; foreach (var file in files) { // .DS_Store文件 if (file.EndsWith(".DS_Store")) { continue; } // *.meta文件 if (file.EndsWith(".meta")) { continue; } // 若为忽略文件,则跳过 if (bcConfig.IsIgnoreFile(bc, file)) { bm.RemoveIgnorFile(file); continue; } bm.AddFile(file); } bundlesMap.Maps.Add(bm); } break; } } } // 目录检测 var checkDir = BundlesResult.GetInstance().BundlesOutputDir; if (Directory.Exists(checkDir) == false) { Directory.CreateDirectory(checkDir); } checkDir = BundlesResult.GetInstance().BundlesOutputDirOfNormal; if (Directory.Exists(checkDir) == false) { Directory.CreateDirectory(checkDir); } checkDir = BundlesResult.GetInstance().BundlesOutputDirOfScene; if (Directory.Exists(checkDir) == false) { Directory.CreateDirectory(checkDir); } var succeeded = false; AssetBundleManifest result = null; string[] allAssets = null; // 一般Bundles try { var targets = bundlesMap.GetAllNormalBundleTargets(); const BuildAssetBundleOptions options = BuildAssetBundleOptions.None; result = BuildPipeline.BuildAssetBundles( BundlesResult.GetInstance().BundlesOutputDirOfNormal, targets, options, iBuildTarget); Loger.BuildLog(" -> BuildPipeline.BuildAssetBundles"); if (result != null) { allAssets = result.GetAllAssetBundles(); if (allAssets != null && targets.Length == allAssets.Length) { succeeded = true; } } } catch (Exception exp) { Loger.BuildErrorLog($"BuildAssetBundles Detail : {exp.Message}"); succeeded = false; } // 更新导出标志位 if (succeeded) { Loger.BuildLog(" -> BundlesConfig.UpdateBundleStateWhenCompleted"); var hashCodes = new Dictionary <string, string>(); foreach (var asset in allAssets) { var hashCode = result.GetAssetBundleHash(asset); if (string.IsNullOrEmpty(hashCode.ToString())) { continue; } var fileSuffix = BundlesResult.GetInstance().FileSuffix; var key = asset; if (string.IsNullOrEmpty(fileSuffix) == false) { fileSuffix = fileSuffix.ToLower(); fileSuffix = $".{fileSuffix}"; key = key.Replace(fileSuffix, ""); } hashCodes[key] = hashCode.ToString(); } // 初始化检测信息(Hash Code) bundlesMap.PushBundleResult(BundleType.Normal, hashCodes); Loger.BuildLog(" -> BundlesMap.UpdateUploadList Normal"); } // Scene Bundles var targetScenes = bundlesMap.GetAllSceneBundleTargets(); if (targetScenes != null && targetScenes.Count > 0) { foreach (var scene in targetScenes) { if (scene?.GetAllTargets() == null || scene.GetAllTargets().Length <= 0) { continue; } try { var options = BuildOptions.BuildAdditionalStreamedScenes; if (BuildMode.Debug == SysSettings.GetInstance().BuildMode) { options |= BuildOptions.Development; } var sceneState = BuildPipeline.BuildPlayer( scene.GetAllTargets(), BundlesResult.GetLocalSceneBundleFilePath(scene.BundleId), iBuildTarget, options); Loger.BuildLog($" -> BuildPipeline.BuildStreamedSceneAssetBundle(State:{sceneState})"); } catch (Exception exp) { Loger.BuildErrorLog($"BuildStreamedSceneAssetBundle Detail:{exp.Message}"); succeeded = false; } } } // 更新导出标志位 if (succeeded) { Loger.BuildLog(" -> BundlesConfig.UpdateBundleStateWhenCompleted"); // 初始化检测信息(Hash Code) bundlesMap.PushBundleResult(BundleType.Scene); Loger.BuildLog(" -> BundlesMap.UpdateUploadList Scene"); } SysSettings.GetInstance().ExportToJsonFile(); Loger.BuildLog(" -> BuildInfo.ExportToJsonFile"); Loger.BuildEnd(); }