protected void Application_Start(object sender, EventArgs e) { AreaRegistration.RegisterAllAreas(); RouteConfig.RegisterRoutes(RouteTable.Routes); BundlesConfig.RegisterBundles(BundleTable.Bundles); GlobalVars.Initialize(); }
protected void Application_Start() { AutofacConfig.Register(); AreaRegistration.RegisterAllAreas(); BundlesConfig.Register(BundleTable.Bundles); RouteConfig.RegisterRoutes(RouteTable.Routes); }
void Application_Start(object sender, EventArgs e) { // Code that runs on application startup AreaRegistration.RegisterAllAreas(); GlobalConfiguration.Configure(WebApiConfig.Register); RouteConfig.RegisterRoutes(RouteTable.Routes); BundlesConfig.RegisterBundles(BundleTable.Bundles); BundleTable.EnableOptimizations = true; }
protected void Application_Start() { AreaRegistration.RegisterAllAreas(); WebApiConfig.Register(GlobalConfiguration.Configuration); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundlesConfig.RegisterBundles(BundleTable.Bundles); setDependencyResolver(); // Create culture info object var ci = new CultureInfo("en"); System.Threading.Thread.CurrentThread.CurrentUICulture = ci; System.Threading.Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(ci.Name); }
protected void Application_Start() { AreaRegistration.RegisterAllAreas(); BundlesConfig.RegisterBundles(BundleTable.Bundles); AutofacConfig.Configure(); RouteTable.Routes.MapMvcAttributeRoutes(); RouteTable.Routes.MapRoute( name: "Default", url: "{controller}/{action}/{id}", defaults: new { controller = "Cliente", action = "Create", id = UrlParameter.Optional } ); Database.SetInitializer <CanvasExtendContenxt>(null); log4net.Config.XmlConfigurator.Configure(); }
void BeginBackgroundDownloadBundles() { #if !UNITY_EDITOR || FORCE_ASSET_BUNDLES_IN_EDITOR // background download bundles BundlesConfig bf = InJoy.AssetBundles.AssetBundles.Load(DataManager.Instance.bundleConfigPath, typeof(BundlesConfig)) as BundlesConfig; foreach (WorldBundlesData wfd in bf._worlds) { if (!wfd._downloadInLaunch) { continue; } bool isAllDownload = true; Debug.Log("start bf(" + wfd._bundles.Length + ")"); foreach (string index in wfd._bundles) { if (index != null && index != "") { Debug.Log("step1:" + index); if (!FCDownloadManager.Instance.IsIndexDownloaded(index)) { Debug.Log("step2:" + index); if (!FCDownloadManager.Instance.IsIndexDownloading(index)) { Debug.Log("step3:" + index); FCDownloadManager.Instance.AddDownloadIndex(index, FCDownloadManager.DownloadType.DT_Background); } isAllDownload = false; } } } if (!isAllDownload) { FCDownloadManagerView.Instance.RegisterDownloadEvent(wfd); } } #endif }
/// <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(); }
/// <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(); }