Ejemplo n.º 1
0
        private void InitTabs()
        {
            var screens = new[] {
                EditScreen.ScreenName,
                BulkScreen.ScreenName,
                MoreScreen.ScreenName,
                PerformanceScreen.ScreenName
            };

            var tabsContainer = _plugin.CreateSpacer(true);

            tabsContainer.height = 60f;

            var group = tabsContainer.gameObject.AddComponent <GridLayoutGroup>();

            group.constraint      = GridLayoutGroup.Constraint.Flexible;
            group.constraintCount = screens.Length;
            group.spacing         = Vector2.zero;
            group.cellSize        = new Vector2(512f / 4f, 50f);
            group.childAlignment  = TextAnchor.MiddleCenter;

            foreach (var screen in screens)
            {
                var changeTo = screen;
                var btn      = UnityEngine.Object.Instantiate(_plugin.manager.configurableButtonPrefab).GetComponent <UIDynamicButton>();
                btn.gameObject.transform.SetParent(group.transform, false);
                btn.label = changeTo;

                btn.button.onClick.AddListener(() =>
                {
                    ChangeScreen(changeTo);
                });

                _screenChanged.AddListener(() =>
                {
                    var selected            = _currentScreen == changeTo;
                    btn.button.interactable = !selected;
                });
            }
        }
Ejemplo n.º 2
0
        protected void InitClipboardUI(bool rightSide)
        {
            var container = plugin.CreateSpacer(rightSide);

            RegisterComponent(container);
            container.height = 60f;

            var group = container.gameObject.AddComponent <GridLayoutGroup>();

            group.constraint      = GridLayoutGroup.Constraint.Flexible;
            group.constraintCount = 3;
            group.spacing         = Vector2.zero;
            group.cellSize        = new Vector2(512f / 3f, 50f);
            group.childAlignment  = TextAnchor.MiddleCenter;

            {
                var btn = UnityEngine.Object.Instantiate(plugin.manager.configurableButtonPrefab).GetComponent <UIDynamicButton>();
                btn.gameObject.transform.SetParent(group.transform, false);
                btn.label = "Cut";
                btn.button.onClick.AddListener(() => plugin.cutJSON.actionCallback());
            }

            {
                var btn = UnityEngine.Object.Instantiate(plugin.manager.configurableButtonPrefab).GetComponent <UIDynamicButton>();
                btn.gameObject.transform.SetParent(group.transform, false);
                btn.label = "Copy";
                btn.button.onClick.AddListener(() => plugin.copyJSON.actionCallback());
            }

            {
                var btn = UnityEngine.Object.Instantiate(plugin.manager.configurableButtonPrefab).GetComponent <UIDynamicButton>();
                btn.gameObject.transform.SetParent(group.transform, false);
                btn.label = "Paste";
                btn.button.onClick.AddListener(() => plugin.pasteJSON.actionCallback());
            }
        }