//Button to go to pipe building form
        private void button1_Click(object sender, EventArgs e)
        {
            BuildPipe back2 = new BuildPipe();

            back2.Show();
            this.Visible = false;
        }
예제 #2
0
    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("资源更新完成");
    }