示例#1
0
 public override void OnUpdate()
 {
     UploadModel.Update();
 }
示例#2
0
 public override void OnClose()
 {
     UploadModel.Dispose();
 }
示例#3
0
        protected override void Init()
        {
            RootLayout = new VerticalLayout("box");
            UploadModel.Subject
            .StartWith(UploadModel.State)
            .Subscribe(state =>
            {
                if (state.Progress == UploadProgress.STATE_GENERATE_INIT)
                {
                    RootLayout.Clear();

                    // 当前版本号
                    var versionLine = new HorizontalLayout().AddTo(RootLayout);
                    new LabelView("当前版本号").Width(100).AddTo(versionLine);
                    new LabelView(mPackageVersion.Version).Width(100).AddTo(versionLine);

                    // 发布版本号
                    var publishedVertionLine = new HorizontalLayout().AddTo(RootLayout);
                    new LabelView("发布版本号").Width(100).AddTo(publishedVertionLine);
                    new TextView(mVersionText).Width(100).AddTo(publishedVertionLine)
                    .Content.Bind(content => mVersionText = content);


                    var typeLine = new HorizontalLayout().AddTo(RootLayout);
                    new LabelView("类型").Width(100).AddTo(typeLine);

                    new EnumPopupView(mPackageVersion.Type).AddTo(typeLine)
                    .ValueProperty.Bind(value => mPackageVersion.Type = (PackageType)value);


                    var accessRightLine = new HorizontalLayout().AddTo(RootLayout);

                    new LabelView("权限").Width(100).AddTo(accessRightLine);

                    new EnumPopupView(mPackageVersion.AccessRight).AddTo(accessRightLine)
                    .ValueProperty.Bind(v => mPackageVersion.AccessRight = (PackageAccessRight)v);

                    new LabelView("发布说明:").Width(150).AddTo(RootLayout);

                    new TextAreaView(mReleaseNote).Width(250).Height(300).AddTo(RootLayout)
                    .Content.Bind(releaseNote => mReleaseNote = releaseNote);

                    var docLine = new HorizontalLayout().AddTo(RootLayout);

                    new LabelView("文档地址:").Width(52).AddTo(docLine);
                    new TextView(mPackageVersion.DocUrl).Width(150).AddTo(docLine)
                    .Content.Bind(value => mPackageVersion.DocUrl = value);

                    new ButtonView("Paste", () =>
                    {
                        mPackageVersion.DocUrl = GUIUtility.systemCopyBuffer;
                    }).AddTo(docLine);


                    if (User.Logined)
                    {
                        new ButtonView("发布", () =>
                        {
                            User.Save();

                            if (mReleaseNote.Length < 2)
                            {
                                ShowErrorMsg("请输入版本修改说明");
                                return;
                            }

                            if (!IsVersionValide(mVersionText))
                            {
                                ShowErrorMsg("请输入正确的版本号");
                                return;
                            }

                            mPackageVersion.Version = mVersionText;
                            mPackageVersion.Readme  = new ReleaseItem(mVersionText, mReleaseNote, User.Username.Value,
                                                                      DateTime.Now);

                            mPackageVersion.Save();

                            AssetDatabase.Refresh();


                            UploadModel.Effects.Publish(mPackageVersion, false);
                        }).AddTo(RootLayout);

                        new ButtonView("发布并删除本地", () => { }).AddTo(RootLayout);
                    }
                }
                else
                {
                    RootLayout.Clear();

                    new CustomView(() =>
                    {
                        EditorGUI.LabelField(new Rect(100, 200, 200, 200), state.NoticeMessage, EditorStyles.boldLabel);
                    }).AddTo(RootLayout);
                }

                if (state.Progress == UploadProgress.STATE_GENERATE_COMPLETE)
                {
                    if (EditorUtility.DisplayDialog("上传结果", mUploadResult, "OK"))
                    {
                        AssetDatabase.Refresh();

                        UploadModel.Dispatch("setProgress", UploadProgress.STATE_GENERATE_INIT);
                        Close();
                    }
                }
            });
        }