public override async Task <bool> Process(PipeContext context) { if (context == null) { throw new System.ArgumentNullException("context"); } if (context.assets == null) { context.assets = new List <AssetEntry>(); } List <string> files = CollectAssetsToBuild(TargetPath); for (int i = 0; i < files.Count; i++) { string assetPath = files[i]; Object obj = AssetDatabase.LoadAssetAtPath(assetPath, typeof(Object)); var type = PipleUtility.GetAssetType(obj); context.assets.Add(new AssetEntry() { assetPath = assetPath, type = type }); } await Task.FromResult(true); return(true); }
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); } }
public override async Task <bool> Process(PipeContext context) { if (context == null) { throw new System.ArgumentNullException("context"); } var assets = context.assets; if (assets == null) { return(true); } AssetEntry[] origins = assets.ToArray(); for (int i = 0; i < origins.Length; i++) { var entry = origins[i]; if (entry == null) { continue; } var assetPath = entry.assetPath; var deps = AssetDatabase.GetDependencies(assetPath, Recursive); for (int j = 0; j < deps.Length; j++) { var depAssetPath = deps[j]; if (depAssetPath.Equals(assetPath)) { continue; } if (assets.Any(v => v.assetPath.Equals(depAssetPath))) { continue; } var depObj = AssetDatabase.LoadAssetAtPath(depAssetPath, typeof(Object)); if (depObj == null) { continue; } if (depObj is MonoScript) { continue; } assets.Add(new AssetEntry() { assetPath = depAssetPath, type = PipleUtility.GetAssetType(depObj) }); } } await Task.FromResult(true); return(true); }
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("资源更新完成"); }