Beispiel #1
0
        private void OnEnable()
        {
            mRootLayout = new VerticalLayout();

            new ButtonView(LocaleText.Generate,
                           () => { CreateViewControllerCode.DoCreateCodeFromScene((target as ViewController).gameObject); })
            .Height(30)
            .AddTo(mRootLayout);

            if (mCodeGenerateInfo.ScriptsFolder.IsNullOrEmpty())
            {
                var setting = UIKitSettingData.Load();
                mCodeGenerateInfo.ScriptsFolder = "Assets" + setting.DefaultViewControllerScriptDir;
            }

            if (mCodeGenerateInfo.PrefabFolder.IsNullOrEmpty())
            {
                var setting = UIKitSettingData.Load();
                mCodeGenerateInfo.PrefabFolder = "Assets" + setting.DefaultViewControllerPrefabDir;
            }

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

            if (mCodeGenerateInfo.Namespace.IsNullOrEmpty())
            {
                var setting = UIKitSettingData.Load();
                mCodeGenerateInfo.Namespace = setting.Namespace;
            }
        }
Beispiel #2
0
        private void OnEnable()
        {
            mRootLayout = new VerticalLayout();

            new ButtonView(LocaleText.Generate,
                           () => { CreateViewControllerCode.DoCreateCodeFromScene((target as ViewController).gameObject); })
            .Height(30)
            .AddTo(mRootLayout);
        }
Beispiel #3
0
        private void OnEnable()
        {
            mRootLayout = new VerticalLayout();

            EasyIMGUI.Button()
            .Text(LocaleText.Generate)
            .OnClick(() =>
            {
                CreateViewControllerCode.DoCreateCodeFromScene(((ViewController)target).gameObject);
                GUIUtility.ExitGUI();
            })
            .Height(30)
            .Parent(mRootLayout);

            if (mCodeGenerateInfo.ScriptsFolder.IsNullOrEmpty())
            {
                var setting = UIKitSettingData.Load();
                mCodeGenerateInfo.ScriptsFolder = "Assets" + setting.DefaultViewControllerScriptDir;
            }

            if (mCodeGenerateInfo.PrefabFolder.IsNullOrEmpty())
            {
                var setting = UIKitSettingData.Load();
                mCodeGenerateInfo.PrefabFolder = "Assets" + setting.DefaultViewControllerPrefabDir;
            }

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

            if (mCodeGenerateInfo.Namespace.IsNullOrEmpty())
            {
                var setting = UIKitSettingData.Load();
                mCodeGenerateInfo.Namespace = setting.Namespace;
            }
        }
Beispiel #4
0
        private void OnEnable()
        {
            mRootLayout = new VerticalLayout("box");

            new SpaceView()
            .AddTo(mRootLayout);

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

            new LabelView(LocaleText.MarkType)
            .FontSize(12)
            .Width(60)
            .AddTo(markTypeLine);

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

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

                OnRefresh();
            });


            new SpaceView()
            .AddTo(mRootLayout);

            new CustomView(() =>
            {
                if (mBindScript.CustomComponentName == null ||
                    string.IsNullOrEmpty(mBindScript.CustomComponentName.Trim()))
                {
                    mBindScript.CustomComponentName = mBindScript.name;
                }
            }).AddTo(mRootLayout);


            mComponentLine = new HorizontalLayout();

            new LabelView(LocaleText.Type)
            .Width(60)
            .FontSize(12)
            .AddTo(mComponentLine);

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

                var componentNames = components.Where(c => c.GetType() != typeof(Bind))
                                     .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)
                .AddTo(mComponentLine)
                .IndexProperty.Bind((index) => { mBindScript.ComponentName = componentNames[index]; });
            }

            mComponentLine.AddTo(mRootLayout);


            new SpaceView()
            .AddTo(mRootLayout);

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

            new LabelView(LocaleText.BelongsTo)
            .Width(60)
            .FontSize(12)
            .AddTo(belongsTo);

            new LabelView(CodeGenUtil.GetBindBelongs2(target as Bind))
            .Width(200)
            .FontSize(12)
            .AddTo(belongsTo);


            new ButtonView(LocaleText.Select, () =>
            {
                Selection.objects = new[]
                {
                    CodeGenUtil.GetBindBelongs2GameObject(target as Bind)
                };
            })
            .Width(60)
            .AddTo(belongsTo);

            mClassnameLine = new HorizontalLayout();

            new LabelView(LocaleText.ClassName)
            .Width(60)
            .FontSize(12)
            .AddTo(mClassnameLine);

            new TextView(mBindScript.CustomComponentName)
            .AddTo(mClassnameLine)
            .Content.Bind(newValue => { mBindScript.CustomComponentName = newValue; });

            mClassnameLine.AddTo(mRootLayout);

            new SpaceView()
            .AddTo(mRootLayout);

            new LabelView(LocaleText.Comment)
            .FontSize(12)
            .AddTo(mRootLayout);

            new SpaceView()
            .AddTo(mRootLayout);

            new TextAreaView(mBindScript.Comment)
            .Height(100)
            .AddTo(mRootLayout)
            .Content.Bind(newValue => mBindScript.CustomComment = newValue);

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


            if (rootGameObj.transform.GetComponent("ILKitBehaviour"))
            {
            }
            else if (rootGameObj.transform.IsUIPanel())
            {
                new ButtonView(LocaleText.Generate + " " + CodeGenUtil.GetBindBelongs2(bind),
                               () =>
                {
                    var rootPrefabObj = PrefabUtility.GetPrefabParent(rootGameObj);


                    UICodeGenerator.DoCreateCode(new[] { rootPrefabObj });
                })
                .Height(30)
                .AddTo(mRootLayout);
            }
            else if (rootGameObj.transform.IsViewController())
            {
                new ButtonView(LocaleText.Generate + " " + CodeGenUtil.GetBindBelongs2(bind),
                               () =>
                {
                    CreateViewControllerCode.DoCreateCodeFromScene(bind.gameObject);
                })
                .Height(30)
                .AddTo(mRootLayout);
            }


            OnRefresh();
        }
Beispiel #5
0
        private void OnEnable()
        {
            mRootLayout = new VerticalLayout("box");

            new SpaceView()
            .AddTo(mRootLayout);

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

            new LabelView(LocaleText.MarkType)
            .FontSize(12)
            .Width(60)
            .AddTo(markTypeLine);

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

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

                OnRefresh();
            });

            new SpaceView()
            .AddTo(mRootLayout);

            new CustomView(() =>
            {
                if (mBindScript.CustomComponentName == null ||
                    string.IsNullOrEmpty(mBindScript.CustomComponentName.Trim()))
                {
                    mBindScript.CustomComponentName = mBindScript.name;
                }
            }).AddTo(mRootLayout);


            mComponentLine = new HorizontalLayout();

            new LabelView(LocaleText.Type)
            .Width(60)
            .FontSize(12)
            .AddTo(mComponentLine);

            new LabelView(mBindScript.ComponentName)
            .FontSize(12)
            .AddTo(mComponentLine);

            mComponentLine.AddTo(mRootLayout);

            new SpaceView()
            .AddTo(mRootLayout);

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

            new LabelView(LocaleText.BelongsTo)
            .Width(60)
            .FontSize(12)
            .AddTo(belongsTo);

            new LabelView(CodeGenUtil.GetBindBelongs2(target as Bind))
            .Width(200)
            .FontSize(12)
            .AddTo(belongsTo);


            new ButtonView(LocaleText.Select, () =>
            {
                Selection.objects = new[]
                {
                    CodeGenUtil.GetBindBelongs2GameObject(target as Bind)
                };
            })
            .Width(60)
            .AddTo(belongsTo);

            mClassnameLine = new HorizontalLayout();

            new LabelView(LocaleText.ClassName)
            .Width(60)
            .FontSize(12)
            .AddTo(mClassnameLine);

            new TextView(mBindScript.CustomComponentName)
            .AddTo(mClassnameLine)
            .Content.Bind(newValue => { mBindScript.CustomComponentName = newValue; });

            mClassnameLine.AddTo(mRootLayout);

            new SpaceView()
            .AddTo(mRootLayout);

            new LabelView(LocaleText.Comment)
            .FontSize(12)
            .AddTo(mRootLayout);

            new SpaceView()
            .AddTo(mRootLayout);

            new TextAreaView(mBindScript.Comment)
            .Height(100)
            .AddTo(mRootLayout)
            .Content.Bind(newValue => mBindScript.CustomComment = newValue);

            new ButtonView(LocaleText.Generate + " " + CodeGenUtil.GetBindBelongs2(target as Bind),
                           () => { CreateViewControllerCode.DoCreateCodeFromScene((target as Bind).gameObject); })
            .Height(30)
            .AddTo(mRootLayout);


            OnRefresh();
        }
Beispiel #6
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();
        }