static async void UpdateToServer() { var setting = AddressableAssetSettingsDefaultObject.Settings; if (setting == null) { return; } // 创建组模板 var groupTemplete = PipleUtility.GetTemplete(setting, false); if (groupTemplete == null) { EditorUtility.DisplayDialog("提示", "上传失败,未找到组模板!", "确定"); return; } var groupTempleteBundleSchema = groupTemplete.GetSchemaByType(typeof(BundledAssetGroupSchema)) as BundledAssetGroupSchema; string groupBuildPath = groupTempleteBundleSchema.BuildPath.GetValue(setting.profileSettings, setting.activeProfileId); string groupLoadPath = groupTempleteBundleSchema.LoadPath.GetValue(setting.profileSettings, setting.activeProfileId); UploadEntryPhase phase = new UploadEntryPhase(); phase.HostType = HostType; phase.Host = Host; phase.UserName = UserName; phase.Password = Password; phase.RemoteBuildPath = groupBuildPath; phase.RemoteLoadPath = groupLoadPath; phase.OnWillProcess = (c) => EditorUtility.DisplayDialog("提示", "是否上传到服务器?", "是", "取消"); PipeContext context = new PipeContext(); try { await phase.Process(context); } catch (Exception e) { Debug.LogException(e); } }
static async void UpdateContent() { // 保存一下项目,否则有些修改将无法起效 if (!NotifySaveProject()) { return; } var systemSetting = GetOrCreateSystemSetting(); if (string.IsNullOrEmpty(systemSetting.BuildFolder)) { Debug.LogError("未设置打包目录."); return; } var setting = AddressableAssetSettingsDefaultObject.Settings; if (setting == null) { return; } // 创建组模板 var groupTemplete = PipleUtility.GetTemplete(setting, true); var groupTempleteBundleSchema = groupTemplete.GetSchemaByType(typeof(BundledAssetGroupSchema)) as BundledAssetGroupSchema; string groupBuildPath = groupTempleteBundleSchema.BuildPath.GetValue(setting.profileSettings, setting.activeProfileId); string groupLoadPath = groupTempleteBundleSchema.LoadPath.GetValue(setting.profileSettings, setting.activeProfileId); PipeContext context = new PipeContext(); context.buildSetting = systemSetting; context.setting = setting; context.groupTemplete = groupTemplete; // 构建内容更新管线 BuildPipe pipe = new BuildPipe(); pipe.AddPhase(new ClearEmptyGroupPhase()); pipe.AddPhase(new CollectBuildEntryPhase() { TargetPath = systemSetting.BuildFolder }); if (systemSetting.ExportDll) { pipe.AddPhase(new CollectDllAsTextPhase()); } pipe.AddPhase(new CollectDependencyPhase()); pipe.AddPhase(new CreateGroupPhase()); pipe.AddPhase(new ModifyEntryAddressPhase()); pipe.AddPhase(new UpdateContentPhase()); if (systemSetting.GeneratePreview) { string previewOutput = Path.Combine(groupBuildPath, "preview").Replace('\\', '/'); pipe.AddPhase(new GeneratePreviewPhase() { OutputPath = previewOutput }); } pipe.AddPhase(new SaveManifestPhase() { OutputPath = groupBuildPath }); pipe.AddPhase(new UploadEntryPhase() { HostType = systemSetting.UploadHostType, Host = systemSetting.UploadHost, UserName = systemSetting.UserName, Password = systemSetting.Password, RemoteBuildPath = groupBuildPath, RemoteLoadPath = groupLoadPath, OnWillProcess = (c) => { return(EditorUtility.DisplayDialog("提示", "是否上传到服务器?", "是", "取消")); } }); try { await pipe.ProcessPiple(context); } catch (System.Exception e) { Debug.LogException(e); } Debug.Log("资源更新完成"); }