Example #1
0
        private void OnGUI()
        {
            EditorGUI.DrawTextureTransparent(new Rect((position.width / 2) - (_logoTexture.width / 2), 0, _logoTexture.width, _logoTexture.height), _logoTexture, ScaleMode.ScaleToFit);
            EditorGUILayout.Space(_logoTexture.height);
            EditorGUILayout.Separator();
            _packageName = EditorGUILayout.TextField("Package file name:", _packageName);
            EditorGUILayout.Separator();


            EditorGUILayout.LabelField("Package assets", EditorStyles.boldLabel);
            _scrollPos = EditorGUILayout.BeginScrollView(_scrollPos);

            _assetTreeGUI.DrawTreeLayout();

            EditorGUILayout.EndScrollView();


            EditorGUILayout.Separator();


            if (GUILayout.Button("Export", GUILayout.Height(30)))
            {
                Export();
            }
            EditorGUILayout.LabelField("yCatDev - Version 1.1", EditorStyles.miniBoldLabel);
        }
Example #2
0
        protected override void Init()
        {
            PackageMakerState.InitState();

            var hashSet = new HashSet <string>();

            if (mPackageVersion.IncludeFileOrFolders.Count == 0 && mPackageVersion.InstallPath.EndsWith("/"))
            {
                hashSet.Add(mPackageVersion.InstallPath.Remove(mPackageVersion.InstallPath.Length - 1));
            }

            foreach (var packageIncludeFileOrFolder in mPackageVersion.IncludeFileOrFolders)
            {
                hashSet.Add(packageIncludeFileOrFolder);
            }

            _assetTree    = new AssetTree();
            _assetTreeGUI = new AssetTreeIMGUI(_assetTree.Root);

            var guids = AssetDatabase.FindAssets(string.Empty);
            int i = 0, l = guids.Length;

            for (; i < l; ++i)
            {
                _assetTree.AddAsset(guids[i], hashSet);
            }

            RootLayout = new VerticalLayout("box");

            var editorView    = EasyIMGUI.Vertical().Parent(RootLayout);
            var uploadingView = new VerticalLayout().Parent(RootLayout);

            // 当前版本号
            var versionLine = EasyIMGUI.Horizontal().Parent(editorView);

            EasyIMGUI.Label().Text("当前版本号").Width(100).Parent(versionLine);
            EasyIMGUI.Label().Text(mPackageVersion.Version).Width(100).Parent(versionLine);

            // 发布版本号
            var publishedVersionLine = new HorizontalLayout().Parent(editorView);

            EasyIMGUI.Label().Text("发布版本号")
            .Width(100)
            .Parent(publishedVersionLine);

            EasyIMGUI.TextField()
            .Text(mPublishVersion)
            .Width(100)
            .Parent(publishedVersionLine)
            .Content.Bind(v => mPublishVersion = v);

            // 类型
            var typeLine = EasyIMGUI.Horizontal().Parent(editorView);

            EasyIMGUI.Label().Text("类型").Width(100).Parent(typeLine);

            var packageType = new EnumPopupView(mPackageVersion.Type).Parent(typeLine);

            var accessRightLine = EasyIMGUI.Horizontal().Parent(editorView);

            EasyIMGUI.Label().Text("权限").Width(100).Parent(accessRightLine);
            var accessRight = new EnumPopupView(mPackageVersion.AccessRight).Parent(accessRightLine);

            EasyIMGUI.Label().Text("发布说明:").Width(150).Parent(editorView);

            var releaseNote = EasyIMGUI.TextArea().Width(245)
                              .Parent(editorView);

            // 文件选择部分
            EasyIMGUI.Label().Text("插件目录: " + mPackageVersion.InstallPath)
            .Parent(editorView);

            EasyIMGUI.Custom().OnGUI(() =>
            {
                _scrollPosition = EditorGUILayout.BeginScrollView(_scrollPosition);

                _assetTreeGUI.DrawTreeLayout();

                EditorGUILayout.EndScrollView();
            }).Parent(editorView);


            PackageMakerState.InEditorView.BindWithInitialValue(value => { editorView.Visible = value; })
            .AddTo(mDisposableList);

            if (User.Logined)
            {
                EasyIMGUI.Button()
                .Text("发布")
                .OnClick(() =>
                {
                    var includedPaths = new List <string>();
                    _assetTree.Root.Traverse(data =>
                    {
                        if (data != null && data.isSelected)
                        {
                            includedPaths.Add(data.fullPath);
                            return(false);
                        }

                        return(true);
                    });

                    mPackageVersion.IncludeFileOrFolders = includedPaths;
                    mPackageVersion.Readme.content       = releaseNote.Content.Value;
                    mPackageVersion.AccessRight          = (PackageAccessRight)accessRight.ValueProperty.Value;
                    mPackageVersion.Type    = (PackageType)packageType.ValueProperty.Value;
                    mPackageVersion.Version = mPublishVersion;
                    mControllerNode.SendCommand(new PublishPackageCommand(mPackageVersion));
                }).Parent(editorView);
            }

            var notice = new LabelViewWithRect("", 100, 200, 200, 200).Parent(uploadingView);

            PackageMakerState.NoticeMessage
            .BindWithInitialValue(value => { notice.Content.Value = value; }).AddTo(mDisposableList);

            PackageMakerState.InUploadingView.BindWithInitialValue(value => { uploadingView.Visible = value; })
            .AddTo(mDisposableList);
        }