コード例 #1
0
        public TreeNode(bool spread, string content, int indent = 0, bool autosaveSpreadState = false)
        {
            if (autosaveSpreadState)
            {
                spread = EditorPrefs.GetBool(content, spread);
            }

            Content = content;
            Spread  = new Property <bool>(spread);

            Style = new GUIStyleProperty(() => EditorStyles.foldout);

            mFirstLine.AddTo(this);
            mFirstLine.AddChild(EasyIMGUI.Space().Pixel(indent));

            if (autosaveSpreadState)
            {
                Spread.Bind(value => EditorPrefs.SetBool(content, value));
            }


            EasyIMGUI.Custom().OnGUI(() => { Spread.Value = EditorGUILayout.Foldout(Spread.Value, Content, true, Style.Value); })
            .AddTo(mFirstLine);

            EasyIMGUI.Custom().OnGUI(() =>
            {
                if (Spread.Value)
                {
                    mSpreadView.DrawGUI();
                }
            }).AddTo(this);
        }
コード例 #2
0
ファイル: CustomView.cs プロジェクト: WangYuHang-97/UnityAPI
        public T Convert <T>(XmlNode node) where T : class
        {
            var custom = EasyIMGUI.Custom();

            foreach (XmlAttribute nodeAttribute in node.Attributes)
            {
                if (nodeAttribute.Name == "Id")
                {
                    custom.Id = nodeAttribute.Value;
                }
            }

            return(custom as T);
        }
コード例 #3
0
        public void OnGUI()
        {
            mScrollPos = GUILayout.BeginScrollView(mScrollPos, true, true, GUILayout.Width(580), GUILayout.Height(300));

            GUILayout.Label("类型:" + mPackageVersion.Type);

            mReadme.items.ForEach(item =>
            {
                EasyIMGUI
                .Custom()
                .OnGUI(() =>
                {
                    GUILayout.BeginHorizontal(EditorStyles.helpBox);
                    GUILayout.BeginVertical();
                    GUILayout.BeginHorizontal();

                    GUILayout.Label("version: " + item.version, GUILayout.Width(130));
                    GUILayout.Label("author: " + item.author);
                    GUILayout.Label("date: " + item.date);

                    if (item.author == User.Username.Value || User.Username.Value == "liangxie")
                    {
                        if (GUILayout.Button("删除"))
                        {
//                            RenderEndCommandExecuter.PushCommand(() =>
//                            {
                            new PackageManagerServer().DeletePackage(item.PackageId,
                                                                     () => { mReadme.items.Remove(item); });
//                            });
                        }
                    }

                    GUILayout.EndHorizontal();
                    GUILayout.Label(item.content);
                    GUILayout.EndVertical();

                    GUILayout.EndHorizontal();
                }).DrawGUI();
            });

            GUILayout.EndScrollView();
        }
コード例 #4
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);
        }
コード例 #5
0
        public void Init(IQFrameworkContainer container)
        {
            Container = container;
            var localPackageVersionModel = this.GetModel <ILocalPackageVersionModel>();

            // 左侧
            mLeftLayout = EasyIMGUI.Vertical()
                          .AddChild(EasyIMGUI.Area().WithRectGetter(() => mLeftRect)
                                    // 间距 20
                                    .AddChild(EasyIMGUI.Vertical()
                                              .AddChild(EasyIMGUI.Space().Pixel(20)))
                                    // 搜索
                                    .AddChild(EasyIMGUI.Horizontal()
                                              .AddChild(EasyIMGUI.Label().Text("搜索:")
                                                        .FontBold()
                                                        .FontSize(12)
                                                        .Width(40)
                                                        ).AddChild(EasyIMGUI.TextField()
                                                                   .Height(20)
                                                                   .Self(search =>
            {
                search.Content
                .Bind(key => { this.SendCommand(new SearchCommand(key)); })
                .AddToDisposeList(mDisposableList);
            })
                                                                   )
                                              )

                                    // 权限
                                    .AddChild(EasyIMGUI.Toolbar()
                                              .Menus(new List <string>()
            {
                "All", PackageAccessRight.Public.ToString(), PackageAccessRight.Private.ToString()
            })
                                              .Self(self =>
            {
                self.IndexProperty.Bind(value =>
                {
                    PackageManagerState.AccessRightIndex.Value = value;
                    this.SendCommand(new SearchCommand(PackageManagerState.SearchKey.Value));
                }).AddToDisposeList(mDisposableList);
            }))
                                    // 分类
                                    .AddChild(
                                        EasyIMGUI.Horizontal()
                                        .AddChild(PopupView.Create()
                                                  .ToolbarStyle()
                                                  .Self(self =>
            {
                self.IndexProperty.Bind(value =>
                {
                    PackageManagerState.CategoryIndex.Value = value;
                    this.SendCommand(new SearchCommand(PackageManagerState.SearchKey.Value));
                }).AddToDisposeList(mDisposableList);

                mCategoriesSelectorView = self;
            }))
                                        )
                                    // 是否是官方
                                    .AddChild(
                                        EasyIMGUI.Horizontal()
                                        .AddChild(EasyIMGUI.Toggle().IsOn(mIsOfficial)
                                                  .Self(t => t.ValueProperty.Bind(v => mIsOfficial = v)))
                                        .AddChild(EasyIMGUI.Label().Text("官方"))
                                        .AddChild(EasyIMGUI.FlexibleSpace())
                                        )
                                    .AddChild(EasyIMGUI.Scroll()
                                              .AddChild(EasyIMGUI.Custom().OnGUI(() =>
            {
                PackageManagerState.PackageRepositories.Value
                .Where(p => p.isOfficial == mIsOfficial)
                .OrderByDescending(p =>
                {
                    var installedVersion = localPackageVersionModel.GetByName(p.name);

                    if (installedVersion == null)
                    {
                        return(-1);
                    }
                    else if (installedVersion.VersionNumber < p.VersionNumber)
                    {
                        return(2);
                    }
                    else if (installedVersion.VersionNumber == p.VersionNumber)
                    {
                        return(1);
                    }
                    else
                    {
                        return(0);
                    }
                })
                .ThenBy(p => p.name)
                .ForEach(p =>
                {
                    GUILayout.BeginVertical("box");

                    GUILayout.BeginHorizontal();
                    {
                        GUILayout.Label(p.name);
                        GUILayout.FlexibleSpace();
                    }
                    GUILayout.EndHorizontal();

                    GUILayout.BeginHorizontal();
                    {
                        EasyIMGUI.Box().Text(p.latestVersion)
                        .Self(self => self.BackgroundColor = Color.green)
                        .DrawGUI();

                        GUILayout.FlexibleSpace();

                        var installedVersion = localPackageVersionModel.GetByName(p.name);

                        if (installedVersion == null)
                        {
                            if (GUILayout.Button(LocaleText.Import))
                            {
                                RenderEndCommandExecutor.PushCommand(() =>
                                {
                                    this.SendCommand(new ImportPackageCommand(p));
                                });
                            }
                        }
                        else if (installedVersion.VersionNumber < p.VersionNumber)
                        {
                            if (GUILayout.Button(LocaleText.Update))
                            {
                                RenderEndCommandExecutor.PushCommand(() =>
                                {
                                    this.SendCommand(new UpdatePackageCommand(p));
                                });
                            }
                        }
                        else if (installedVersion.VersionNumber == p.VersionNumber)
                        {
                            if (GUILayout.Button(LocaleText.Reimport))
                            {
                                RenderEndCommandExecutor.PushCommand(() =>
                                {
                                    this.SendCommand(new ReimportPackageCommand(p));
                                });
                            }
                        }
                    }
                    GUILayout.EndHorizontal();

                    GUILayout.EndVertical();

                    var rect = GUILayoutUtility.GetLastRect();

                    if (mSelectedPackageRepository == p)
                    {
                        GUI.Box(rect, "", mSelectionRect);
                    }

                    if (rect.Contains(Event.current.mousePosition) &&
                        Event.current.type == EventType.MouseUp)
                    {
                        mSelectedPackageRepository = p;
                        Event.current.Use();
                    }
                });
            }))
                                              )
                                    );

            // var skin = AssetDatabase.LoadAssetAtPath<GUISkin>(
            var skin = AssetDatabase.LoadAssetAtPath <GUISkin>(
                "Assets/QFramework/Framework/Toolkits/Core/Editor/Markdown/Skin/MarkdownSkinQS.guiskin");


            mMarkdownViewer = new MarkdownViewer(skin, string.Empty, "");
            // 右侧
            mRightLayout = EasyIMGUI.Vertical()
                           .AddChild(EasyIMGUI.Area().WithRectGetter(() => mRightRect)
                                     // 间距 20
                                     .AddChild(EasyIMGUI.Vertical()
                                               .AddChild(EasyIMGUI.Space().Pixel(20))
                                               )
                                     // 详细信息
                                     .AddChild(EasyIMGUI.Vertical()
                                               .WithVisibleCondition(() => mSelectedPackageRepository != null)
                                               // 名字
                                               .AddChild(EasyIMGUI.Label()
                                                         .TextGetter(() => mSelectedPackageRepository.name)
                                                         .FontSize(30)
                                                         .FontBold())
                                               .AddChild(EasyIMGUI.Space())
                                               // 服务器版本
                                               .AddChild(EasyIMGUI.Label()
                                                         .TextGetter(() => "服务器版本: " + mSelectedPackageRepository.latestVersion)
                                                         .FontSize(15))
                                               // 本地版本
                                               .AddChild(EasyIMGUI.Label()
                                                         .WithVisibleCondition(() =>
                                                                               localPackageVersionModel.GetByName(mSelectedPackageRepository.name).IsNotNull())
                                                         .TextGetter(() =>
                                                                     "本地版本:" + localPackageVersionModel.GetByName(mSelectedPackageRepository.name).Version)
                                                         .FontSize(15))
                                               // 作者
                                               .AddChild(EasyIMGUI.Label()
                                                         .TextGetter(() => "作者:" + mSelectedPackageRepository.author)
                                                         .FontSize(15))
                                               // 权限
                                               .AddChild(EasyIMGUI.Label()
                                                         .TextGetter(() => "权限:" + mSelectedPackageRepository.accessRight)
                                                         .FontSize(15))
                                               // 主页
                                               .AddChild(
                                                   EasyIMGUI.Horizontal()
                                                   .AddChild(EasyIMGUI.Label()
                                                             .FontSize(15)
                                                             .Text("插件主页:"))
                                                   .AddChild(EasyIMGUI.Button()
                                                             .TextGetter(() => UrlHelper.PackageUrl(mSelectedPackageRepository))
                                                             .FontSize(15)
                                                             .OnClick(() =>
            {
                this.SendCommand(new OpenDetailCommand(mSelectedPackageRepository));
            })
                                                             )
                                                   .AddChild(EasyIMGUI.FlexibleSpace())
                                                   )
                                               // 描述
                                               .AddChild(EasyIMGUI.Label()
                                                         .TextGetter(() => "描述:")
                                                         .FontSize(15)
                                                         )
                                               .AddChild(EasyIMGUI.Space())
                                               // 描述内容
                                               .AddChild(EasyIMGUI.Custom().OnGUI(() =>
            {
                mMarkdownViewer.UpdateText(mSelectedPackageRepository.description);
                var lastRect = GUILayoutUtility.GetLastRect();
                mMarkdownViewer.DrawWithRect(new Rect(lastRect.x, lastRect.y + lastRect.height,
                                                      mRightRect.width - 210, mRightRect.height - lastRect.y - lastRect.height));
                // mMarkdownViewer.Draw();
            }))
                                               )
                                     );

            mPackageKitWindow = EditorWindow.GetWindow <PackageKitWindow>();

            this.SendCommand <PackageManagerInitCommand>();


            PackageManagerState.Categories.Bind(value =>
            {
                mCategoriesSelectorView.Menus(value);
                mPackageKitWindow.Repaint();
            }).AddToDisposeList(mDisposableList);


            // 创建双屏
            mSplitView = mSplitView = new VerticalSplitView
            {
                Split   = 240,
                fistPan = rect =>
                {
                    mLeftRect = rect;
                    mLeftLayout.DrawGUI();
                },
                secondPan = rect =>
                {
                    mRightRect = rect;
                    mRightLayout.DrawGUI();
                }
            };
        }
コード例 #6
0
        private void OnEnable()
        {
            if (mSerializedObject.IsNull())
            {
                mSerializedObject = new SerializedObject(target);
            }

            mRootLayout = new VerticalLayout();

            if (mCodeGenerateInfo.Namespace.IsNullOrEmpty())
            {
                mCodeGenerateInfo.Namespace = UIKitSettingData.GetProjectNamespace();
            }

            if (mCodeGenerateInfo.ScriptsFolder.IsNullOrEmpty())
            {
                mCodeGenerateInfo.ScriptsFolder = "Assets" + UIKitSettingData.GetScriptsPath();
            }

            if (mCodeGenerateInfo.ScriptName.IsNullOrEmpty())
            {
                mCodeGenerateInfo.ScriptName = mCodeGenerateInfo.gameObject.name;
            }

            new HorizontalLayout()
            .AddChild(EasyIMGUI.Label().Text(LocaleText.Namespace).Width(150))
            .AddChild(EasyIMGUI.TextField().Text(mCodeGenerateInfo.Namespace).Do(v =>
            {
                v.Content.Bind((newValue) =>
                {
                    mCodeGenerateInfo.Namespace = newValue;
                    EditorUtility.SetDirty(mCodeGenerateInfo);
                });
            }))
            .AddTo(mRootLayout);

            new HorizontalLayout()
            .AddChild(EasyIMGUI.Label().Text(LocaleText.ScriptName)).Width(150)
            .AddChild(EasyIMGUI.TextField().Text(mCodeGenerateInfo.ScriptName).Do(v =>
            {
                v.Content.Bind((newValue) =>
                {
                    mCodeGenerateInfo.ScriptName = newValue;
                    EditorUtility.SetDirty(mCodeGenerateInfo);
                });
            }))
            .AddTo(mRootLayout);


            new HorizontalLayout()
            .AddChild(EasyIMGUI.Label().Text(LocaleText.ScriptsFolder).Width(150))
            .AddChild(EasyIMGUI.TextField().Text(mCodeGenerateInfo.ScriptsFolder).Do(v =>
            {
                v.Content.Bind((newValue) =>
                {
                    mCodeGenerateInfo.ScriptsFolder = newValue;
                    EditorUtility.SetDirty(mCodeGenerateInfo);
                });

                mScriptFolderView = v;
            }))
            .AddTo(mRootLayout);

            EasyIMGUI.Custom().OnGUI(() =>
            {
                EditorGUILayout.Space();
                EditorGUILayout.LabelField("请将要生成脚本的文件夹拖到下边区域 或 自行填写目录到上一栏中");
                var sfxPathRect    = EditorGUILayout.GetControlRect();
                sfxPathRect.height = 200;
                GUI.Box(sfxPathRect, string.Empty);
                EditorGUILayout.LabelField(string.Empty, GUILayout.Height(185));
                if (
                    Event.current.type == EventType.DragUpdated &&
                    sfxPathRect.Contains(Event.current.mousePosition)
                    )
                {
                    //改变鼠标的外表
                    DragAndDrop.visualMode = DragAndDropVisualMode.Generic;
                    if (DragAndDrop.paths != null && DragAndDrop.paths.Length > 0)
                    {
                        if (DragAndDrop.paths[0] != "")
                        {
                            var newPath = DragAndDrop.paths[0];
                            mScriptFolderView.Content.Value = newPath;
                            AssetDatabase.SaveAssets();
                            AssetDatabase.Refresh();
                            EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
                        }
                    }
                }

                var fileFullPath = mCodeGenerateInfo.ScriptsFolder + "/" + mCodeGenerateInfo.ScriptName + ".cs";
                if (File.Exists(mCodeGenerateInfo.ScriptsFolder + "/" + mCodeGenerateInfo.ScriptName + ".cs"))
                {
                    var scriptObject = AssetDatabase.LoadAssetAtPath <MonoScript>(fileFullPath);
                    if (GUILayout.Button("打开脚本", GUILayout.Height(30)))
                    {
                        AssetDatabase.OpenAsset(scriptObject);
                    }

                    if (GUILayout.Button("选择脚本", GUILayout.Height(30)))
                    {
                        Selection.objects = new Object[] { scriptObject };
                    }
                }
            }).AddTo(mRootLayout);

            EasyIMGUI.Button()
            .Text(LocaleText.Generate)
            .OnClick(() =>
            {
                if (mCodeGenerateInfo.GetComponent <UIDefaultPanel>())
                {
                    CreateILBehaviourCode.DoCreateCodeFromScene(mCodeGenerateInfo.gameObject, true);
                }
                else
                {
                    CreateILBehaviourCode.DoCreateCodeFromScene(mCodeGenerateInfo.gameObject);
                }
            })
            .Height(30)
            .AddTo(mRootLayout);
        }
コード例 #7
0
        private void OnEnable()
        {
            mRootLayout = new VerticalLayout("box");

            EasyIMGUI.Space()
            .Parent(mRootLayout);

            var markTypeLine = EasyIMGUI.Horizontal()
                               .Parent(mRootLayout);

            EasyIMGUI.Label().Text(LocaleText.MarkType)
            .FontSize(12)
            .Width(60)
            .Parent(markTypeLine);

            var enumPopupView = new EnumPopupView(mBindScript.MarkType)
                                .Parent(markTypeLine);

            enumPopupView.ValueProperty.Bind(newValue =>
            {
                mBindScript.MarkType = (BindType)newValue;

                OnRefresh();
            });


            EasyIMGUI.Space()
            .Parent(mRootLayout);

            EasyIMGUI.Custom().OnGUI(() =>
            {
                if (mBindScript.CustomComponentName == null ||
                    string.IsNullOrEmpty(mBindScript.CustomComponentName.Trim()))
                {
                    mBindScript.CustomComponentName = mBindScript.name;
                }
            }).Parent(mRootLayout);


            mComponentLine = EasyIMGUI.Horizontal();

            EasyIMGUI.Label().Text(LocaleText.Type)
            .Width(60)
            .FontSize(12)
            .Parent(mComponentLine);

            if (mBindScript.MarkType == BindType.DefaultUnityElement)
            {
                var components = mBindScript.GetComponents <Component>();

                var componentNames = components.Where(c => !(c is AbstractBind))
                                     .Select(c => c.GetType().FullName)
                                     .ToArray();

                var componentNameIndex = 0;

                componentNameIndex = componentNames.ToList()
                                     .FindIndex((componentName) => componentName.Contains(mBindScript.ComponentName));

                if (componentNameIndex == -1 || componentNameIndex >= componentNames.Length)
                {
                    componentNameIndex = 0;
                }

                mBindScript.ComponentName = componentNames[componentNameIndex];

                new PopupView(componentNameIndex, componentNames)
                .Parent(mComponentLine)
                .IndexProperty.Bind((index) => { mBindScript.ComponentName = componentNames[index]; });
            }

            mComponentLine.Parent(mRootLayout);

            EasyIMGUI.Space()
            .Parent(mRootLayout);

            var belongsTo = EasyIMGUI.Horizontal()
                            .Parent(mRootLayout);

            EasyIMGUI.Label().Text(LocaleText.BelongsTo)
            .Width(60)
            .FontSize(12)
            .Parent(belongsTo);

            EasyIMGUI.Label().Text(CodeGenUtil.GetBindBelongs2(target as AbstractBind))
            .Width(200)
            .FontSize(12)
            .Parent(belongsTo);


            EasyIMGUI.Button()
            .Text(LocaleText.Select)
            .OnClick(() =>
            {
                Selection.objects = new Object[]
                {
                    CodeGenUtil.GetBindBelongs2GameObject(target as AbstractBind)
                };
            })
            .Width(60)
            .Parent(belongsTo);

            mClassnameLine = new HorizontalLayout();

            EasyIMGUI.Label().Text(LocaleText.ClassName)
            .Width(60)
            .FontSize(12)
            .Parent(mClassnameLine);

            EasyIMGUI.TextField().Text(mBindScript.CustomComponentName)
            .Parent(mClassnameLine)
            .Content.Bind(newValue => { mBindScript.CustomComponentName = newValue; });

            mClassnameLine.Parent(mRootLayout);

            EasyIMGUI.Space()
            .Parent(mRootLayout);

            EasyIMGUI.Label().Text(LocaleText.Comment)
            .FontSize(12)
            .Parent(mRootLayout);

            EasyIMGUI.Space()
            .Parent(mRootLayout);

            EasyIMGUI.TextArea()
            .Text(mBindScript.Comment)
            .Height(100)
            .Parent(mRootLayout)
            .Content.Bind(newValue => mBindScript.CustomComment = newValue);

            var bind        = target as AbstractBind;
            var rootGameObj = CodeGenUtil.GetBindBelongs2GameObject(bind);


            if (rootGameObj.transform.GetComponent("ILKitBehaviour"))
            {
            }
            else if (rootGameObj.transform.IsUIPanel())
            {
                EasyIMGUI.Button()
                .Text(LocaleText.Generate + " " + CodeGenUtil.GetBindBelongs2(bind))
                .OnClick(() =>
                {
                    var rootPrefabObj = PrefabUtility.GetPrefabParent(rootGameObj);
                    UICodeGenerator.DoCreateCode(new[] { rootPrefabObj });
                })
                .Height(30)
                .Parent(mRootLayout);
            }
            else if (rootGameObj.transform.IsViewController())
            {
                EasyIMGUI.Button()
                .Text(LocaleText.Generate + " " + CodeGenUtil.GetBindBelongs2(bind))
                .OnClick(() => { CreateViewControllerCode.DoCreateCodeFromScene(bind.gameObject); })
                .Height(30)
                .Parent(mRootLayout);
            }


            OnRefresh();
        }
コード例 #8
0
        public void Init(IQFrameworkContainer container)
        {
            SerializeHelper.SerializeContainer.RegisterInstance <IJsonSerializer>(new JsonDotnetSerializer());

            mRootLayout = new VerticalLayout();

            EasyIMGUI.Label().Text("ScriptKitILRuntime 的编辑器").FontSize(12).Parent(mRootLayout);

            //EditorStyles.popup.fixedHeight = 30;

            var verticalLayout = new VerticalLayout("box").Parent(mRootLayout);

            var versionText = "0";

            verticalLayout.AddChild(new HorizontalLayout()
                                    .AddChild(EasyIMGUI.Label().Text("版本号(数字):"))
                                    .AddChild(EasyIMGUI.TextField()
                                              .Text(versionText)
                                              .Self(text => text.Content.Bind(t => versionText = t)))
                                    );

            var versionBtn = EasyIMGUI.Button();

            versionBtn.AddLayoutOption(GUILayout.Height(30));
            verticalLayout.AddChild(versionBtn.Text("生成版本信息").OnClick(() =>
            {
                var generatePath = Application.streamingAssetsPath + "/AssetBundles/" +
                                   AssetBundleSettings.GetPlatformForAssetBundles(Application.platform) + "/";

                var filenames = Directory.GetFiles(generatePath);

                new DLLVersion()
                {
                    Assets  = filenames.Select(f => f.GetFileName()).ToList(),
                    Version = versionText.ToInt()
                }.SaveJson(generatePath + "/hotfix.json");

                AssetDatabase.Refresh();
            }));

            EasyIMGUI.Custom().OnGUI(() =>
            {
                GUILayout.BeginVertical();
                {
                    showGenDll = EditorGUILayout.BeginFoldoutHeaderGroup(showGenDll, "编译热更dll");
                    if (showGenDll)
                    {
                        GUILayout.BeginHorizontal();
                        if (GUILayout.Button("编译dll(Debug)", GUILayout.Height(30)))
                        {
                            var outpath_win = Application.streamingAssetsPath + "/AssetBundles/" +
                                              AssetBundleSettings.GetPlatformForAssetBundles(Application.platform);
                            ScriptBuildTools.BuildDll(outpath_win, ScriptBuildTools.BuildMode.Debug);
                        }
                        if (GUILayout.Button("编译dll(Release)", GUILayout.Height(30)))
                        {
                            var outpath_win = Application.streamingAssetsPath + "/AssetBundles/" +
                                              AssetBundleSettings.GetPlatformForAssetBundles(Application.platform);
                            ScriptBuildTools.BuildDll(outpath_win, ScriptBuildTools.BuildMode.Release);
                        }
                        GUILayout.EndHorizontal();
                        GUI.color = Color.green;
                        GUILayout.Label(
                            @"注意事项:
     1.编译服务使用Roslyn,请放心使用
     2.如编译出现报错,请仔细看报错信息,和报错的代码行列,
       一般均为语法错
     3.语法报错原因可能有:主工程访问hotfix中的类, 使用宏
       编译时代码结构发生变化..等等,需要细心的你去发现"
                            );
                        GUI.color = GUI.backgroundColor;
                    }
                    EditorGUILayout.EndFoldoutHeaderGroup();

                    showGenAdapter = EditorGUILayout.BeginFoldoutHeaderGroup(showGenAdapter, "生成跨域Adapter");
                    if (showGenAdapter)
                    {
                        GUILayout.BeginHorizontal();
                        GUILayout.Label("程序集名:");
                        assemblyName = GUILayout.TextField(assemblyName);
                        GUILayout.EndHorizontal();
                        EditorGUILayout.HelpBox("类名如果有命名空间需要带上", MessageType.Info);
                        GUILayout.BeginHorizontal();
                        GUILayout.Label("类名:");
                        adapterClassName = GUILayout.TextField(adapterClassName);
                        GUILayout.EndHorizontal();
                        if (GUILayout.Button("生成", GUILayout.Height(30)))
                        {
                            GenCrossBindAdapter();
                        }
                    }
                    EditorGUILayout.EndFoldoutHeaderGroup();

                    showGenDllBind = EditorGUILayout.BeginFoldoutHeaderGroup(showGenDllBind, "Clr Binding And Link");
                    if (showGenDllBind)
                    {
                        GUILayout.BeginHorizontal();
                        if (GUILayout.Button("生成Clr绑定(不知道干嘛别点!)", GUILayout.Height(30)))
                        {
                            GenClrBindingByAnalysis();
                        }
                        if (GUILayout.Button("生成Link.xml", GUILayout.Height(30)))
                        {
                            StripCode.GenLinkXml();
                        }
                        GUILayout.EndHorizontal();
                    }

                    EditorGUILayout.EndFoldoutHeaderGroup();
                }
                GUILayout.EndVertical();
            }).Parent(verticalLayout);

            var runModelPop = new EnumPopupView(ILRuntimeScriptSetting.Default.HotfixRunMode);

            runModelPop.Style.Value.fixedHeight = 30;
            runModelPop.AddLayoutOption(GUILayout.Height(30));
            runModelPop.ValueProperty.Bind(v => ILRuntimeScriptSetting.Default.HotfixRunMode = (HotfixCodeRunMode)v);
            EasyIMGUI.Horizontal().AddChild(EasyIMGUI.Label().Text("运行模式")).AddChild(runModelPop).Parent(mRootLayout);
        }