Exemple #1
0
            public void Init(IQFrameworkContainer container)
            {
                var expendLayout = new TreeNode(true, LocaleText.ResKit, autosaveSpreadState: true)
                                   .AddTo(this);

                var verticalLayout = new VerticalLayout("box");

                expendLayout.Add2Spread(verticalLayout);

                var persistLine = new HorizontalLayout();

                new LabelView("PersistantPath:").AddTo(persistLine).Width(100);
                new TextView(Application.persistentDataPath).AddTo(persistLine);
                persistLine.AddTo(verticalLayout);

                new ButtonView(LocaleText.GoToPersistent,
                               () => { EditorUtility.RevealInFinder(Application.persistentDataPath); }).AddTo(verticalLayout);

                mResVersion          = EditorPrefs.GetString(KEY_QAssetBundleBuilder_RESVERSION, "100");
                mEnableGenerateClass = EditorPrefs.GetBool(KEY_AUTOGENERATE_CLASS, true);

                switch (EditorUserBuildSettings.activeBuildTarget)
                {
                case BuildTarget.WebGL:
                    mBuildTargetIndex = 3;
                    break;

                case BuildTarget.Android:
                    mBuildTargetIndex = 2;
                    break;

                case BuildTarget.iOS:
                    mBuildTargetIndex = 1;
                    break;

                default:
                    mBuildTargetIndex = 0;
                    break;
                }

                new ToolbarView(mBuildTargetIndex)
                .AddMenu("win/osx", (_) => { })
                .AddMenu("iOS", (_) => { })
                .AddMenu("Android", (_) => { })
                .AddMenu("WebGL", (_) => { })
                .AddTo(verticalLayout);

                new ToggleView(LocaleText.AutoGenerateClass, mEnableGenerateClass)
                .AddTo(verticalLayout)
                .Toggle.Bind(v => mEnableGenerateClass = v);

                new ToggleView(LocaleText.SimulationMode, AssetBundleSettings.SimulateAssetBundleInEditor)
                .AddTo(verticalLayout)
                .Toggle.Bind(v => AssetBundleSettings.SimulateAssetBundleInEditor = v);

                var resVersionLine = new HorizontalLayout()
                                     .AddTo(verticalLayout);

                new LabelView("ResVesion:").AddTo(resVersionLine).Width(100);

                new TextView(mResVersion).AddTo(resVersionLine)
                .Content.Bind(v => mResVersion = v);

                new ButtonView(LocaleText.GenerateClass, () =>
                {
                    BuildScript.WriteClass();
                    AssetDatabase.Refresh();
                }).AddTo(verticalLayout);

                new ButtonView(LocaleText.Build, () =>
                {
                    EditorLifecycle.PushCommand(() =>
                    {
                        var window = container.Resolve <EditorWindow>();

                        if (window)
                        {
                            window.Close();
                        }

                        BuildWithTarget(EditorUserBuildSettings.activeBuildTarget);
                    });
                }).AddTo(verticalLayout);

                new ButtonView(LocaleText.ForceClear, () => { ForceClear(); }).AddTo(verticalLayout);

                verticalLayout.AddChild(new SpaceView(10));
                verticalLayout.AddChild(new LabelView("已标记 AB 列表:").FontBold().FontSize(15));


                var scrollView = new ScrollLayout().AddTo(verticalLayout);

                mMarkedPathList = new VerticalLayout("box")
                                  .AddTo(scrollView);

                ReloadMarkedList();
            }
Exemple #2
0
 private void OnDisable()
 {
     mRootLayout.Clear();
     mRootLayout = null;
 }
Exemple #3
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];

                PopupView.Create()
                .WithIndexAndMenus(componentNameIndex, componentNames)
                .OnIndexChanged(index => { mBindScript.ComponentName = componentNames[index]; })
                .Parent(mComponentLine);
            }

            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.GetCorrespondingObjectFromSource <Object>(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();
        }
Exemple #4
0
        public void Init(IQFrameworkContainer container)
        {
            mViewModel = new UIKitSettingViewModel();

            new LabelView(LocaleText.UIKitSettings).FontSize(12).AddTo(this);

            mRootLayout = new VerticalLayout("box").AddTo(this);

            mRootLayout.AddChild(new SpaceView(6));

            // 命名空间
            var nameSpaceLayout = new HorizontalLayout()
                                  .AddTo(mRootLayout);

            new LabelView(LocaleText.Namespace)
            .FontSize(12)
            .FontBold()
            .Width(200)
            .AddTo(nameSpaceLayout);

            new TextView(mUiKitSettingData.Namespace)
            .AddTo(nameSpaceLayout)
            .Content.Bind(content => mUiKitSettingData.Namespace = content);

            // UI 生成的目录
            new SpaceView(6)
            .AddTo(mRootLayout);

            var uiScriptGenerateDirLayout = new HorizontalLayout()
                                            .AddTo(mRootLayout);

            new LabelView(LocaleText.UIScriptGenerateDir)
            .FontSize(12)
            .FontBold()
            .Width(200)
            .AddTo(uiScriptGenerateDirLayout);

            new TextView(mUiKitSettingData.UIScriptDir)
            .AddTo(uiScriptGenerateDirLayout)
            .Content.Bind(content => mUiKitSettingData.UIScriptDir = content);

            mRootLayout.AddChild(new SpaceView(6));

            var uiPanelPrefabDir = new HorizontalLayout()
                                   .AddTo(mRootLayout);

            new LabelView(LocaleText.UIPanelPrefabDir)
            .FontSize(12)
            .FontBold()
            .Width(200)
            .AddTo(uiPanelPrefabDir);

            new TextView(mUiKitSettingData.UIPrefabDir)
            .AddTo(uiPanelPrefabDir)
            .Content.Bind(content => mUiKitSettingData.UIPrefabDir = content);

            mRootLayout.AddChild(new SpaceView(6));

            // UI 生成的目录
            new SpaceView(6)
            .AddTo(mRootLayout);

            var viewControllerScriptGenerateDirLayout = new HorizontalLayout()
                                                        .AddTo(mRootLayout);

            new LabelView(LocaleText.ViewControllerScriptGenerateDir)
            .FontSize(12)
            .FontBold()
            .Width(200)
            .AddTo(viewControllerScriptGenerateDirLayout);

            new TextView(mUiKitSettingData.DefaultViewControllerScriptDir)
            .AddTo(viewControllerScriptGenerateDirLayout)
            .Content.Bind(content => mUiKitSettingData.DefaultViewControllerScriptDir = content);


            mRootLayout.AddChild(new SpaceView(6));

            var viewControllerPrefabDir = new HorizontalLayout()
                                          .AddTo(mRootLayout);

            new LabelView(LocaleText.ViewControllerPrefabGenerateDir)
            .FontSize(12)
            .FontBold()
            .Width(220)
            .AddTo(viewControllerPrefabDir);

            new TextView(mUiKitSettingData.DefaultViewControllerPrefabDir)
            .AddTo(viewControllerPrefabDir)
            .Content.Bind(content => mUiKitSettingData.DefaultViewControllerPrefabDir = content);

            mRootLayout.AddChild(new SpaceView(6));

            // 保存数据
            new ButtonView(LocaleText.Apply, () => { mUiKitSettingData.Save(); })
            .AddTo(mRootLayout);


            new TextView(mViewModel.PanelNameToCreate)
            .AddTo(mRootLayout)
            .Do(text =>
            {
                text.Content.Bind(txt => mViewModel.PanelNameToCreate = txt);
            });

            // 创建 UI 界面 按钮的绑定
            new ButtonView(LocaleText.CreateUIPanel)
            .AddTo(mRootLayout)
            .Do(btn => btn.OnClick.AddListener(() => { mViewModel.OnCreateUIPanelClick(); }));
        }