public void ToggleShow()
        {
            if (!Hiding)
            {
                Hiding = true;

                m_hideText.text = "►";
                m_titleObj.SetActive(false);
                m_sceneDropdownObj.SetActive(false);
                m_scenePathGroupObj.SetActive(false);
                m_scrollObj.SetActive(false);
                m_pageHandler.Hide();

                m_leftLayout.minWidth = 15;
            }
            else
            {
                Hiding = false;

                m_hideText.text = "Hide Scene Explorer";
                m_titleObj.SetActive(true);
                m_sceneDropdownObj.SetActive(true);
                m_scenePathGroupObj.SetActive(true);
                m_scrollObj.SetActive(true);

                m_leftLayout.minWidth = 350;

                Update();
            }

            InvokeOnToggleShow();
        }
        public void ToggleShow()
        {
            if (!Hiding)
            {
                Hiding = true;

                m_hideText.text = "►";
                m_mainContent.SetActive(false);
                m_pageHandler.Hide();
            }
            else
            {
                Hiding = false;

                m_hideText.text = "◄";
                m_mainContent.SetActive(true);
                m_pageHandler.Show();

                Update();
            }

            InvokeOnToggleShow();
        }
Exemple #3
0
        public void ConstructScenePane()
        {
            GameObject    leftPane   = UIFactory.CreateVerticalGroup(HomePage.Instance.Content, new Color(72f / 255f, 72f / 255f, 72f / 255f));
            LayoutElement leftLayout = leftPane.AddComponent <LayoutElement>();

            leftLayout.minWidth      = 350;
            leftLayout.flexibleWidth = 0;

            VerticalLayoutGroup leftGroup = leftPane.GetComponent <VerticalLayoutGroup>();

            leftGroup.padding.left           = 4;
            leftGroup.padding.right          = 4;
            leftGroup.padding.top            = 8;
            leftGroup.padding.bottom         = 4;
            leftGroup.spacing                = 4;
            leftGroup.childControlWidth      = true;
            leftGroup.childControlHeight     = true;
            leftGroup.childForceExpandWidth  = true;
            leftGroup.childForceExpandHeight = true;

            GameObject titleObj   = UIFactory.CreateLabel(leftPane, TextAnchor.UpperLeft);
            Text       titleLabel = titleObj.GetComponent <Text>();

            titleLabel.text     = "Scene Explorer";
            titleLabel.fontSize = 20;
            LayoutElement titleLayout = titleObj.AddComponent <LayoutElement>();

            titleLayout.minHeight      = 30;
            titleLayout.flexibleHeight = 0;

            GameObject    sceneDropdownObj = UIFactory.CreateDropdown(leftPane, out m_sceneDropdown);
            LayoutElement dropdownLayout   = sceneDropdownObj.AddComponent <LayoutElement>();

            dropdownLayout.minHeight      = 40;
            dropdownLayout.flexibleHeight = 0;
            dropdownLayout.minWidth       = 320;
            dropdownLayout.flexibleWidth  = 2;

            m_sceneDropdownText = m_sceneDropdown.transform.Find("Label").GetComponent <Text>();
            m_sceneDropdown.onValueChanged.AddListener((int val) => { SetSceneFromDropdown(val); });

            void SetSceneFromDropdown(int val)
            {
                //string scene = m_sceneDropdown.options[val].text;
                SetTargetScene(m_currentScenes[val]);
            }

            GameObject            scenePathGroupObj = UIFactory.CreateHorizontalGroup(leftPane, new Color(1, 1, 1, 0f));
            HorizontalLayoutGroup scenePathGroup    = scenePathGroupObj.GetComponent <HorizontalLayoutGroup>();

            scenePathGroup.childControlHeight     = true;
            scenePathGroup.childControlWidth      = true;
            scenePathGroup.childForceExpandHeight = true;
            scenePathGroup.childForceExpandWidth  = true;
            scenePathGroup.spacing = 5;
            LayoutElement scenePathLayout = scenePathGroupObj.AddComponent <LayoutElement>();

            scenePathLayout.minHeight     = 20;
            scenePathLayout.minWidth      = 335;
            scenePathLayout.flexibleWidth = 0;

            m_backButtonObj = UIFactory.CreateButton(scenePathGroupObj);
            Text backButtonText = m_backButtonObj.GetComponentInChildren <Text>();

            backButtonText.text = "◄";
            LayoutElement backButtonLayout = m_backButtonObj.AddComponent <LayoutElement>();

            backButtonLayout.minWidth      = 40;
            backButtonLayout.flexibleWidth = 0;
            Button backButton = m_backButtonObj.GetComponent <Button>();
            var    colors     = backButton.colors;

            colors.normalColor = new Color(0.12f, 0.12f, 0.12f);
            backButton.colors  = colors;

            backButton.onClick.AddListener(() => { SetSceneObjectParent(); });

            void SetSceneObjectParent()
            {
                if (!m_selectedSceneObject || !m_selectedSceneObject.transform.parent?.gameObject)
                {
                    m_selectedSceneObject = null;
                    SetTargetScene(m_currentScene);
                }
                else
                {
                    SetTargetObject(m_selectedSceneObject.transform.parent.gameObject);
                }
            }

            GameObject scenePathLabel = UIFactory.CreateHorizontalGroup(scenePathGroupObj);
            Image      image          = scenePathLabel.GetComponent <Image>();

            image.color = Color.white;

            LayoutElement scenePathLabelLayout = scenePathLabel.AddComponent <LayoutElement>();

            scenePathLabelLayout.minWidth       = 210;
            scenePathLabelLayout.minHeight      = 20;
            scenePathLabelLayout.flexibleHeight = 0;
            scenePathLabelLayout.flexibleWidth  = 120;

            scenePathLabel.AddComponent <Mask>().showMaskGraphic = false;

            GameObject scenePathLabelText = UIFactory.CreateLabel(scenePathLabel, TextAnchor.MiddleLeft);

            m_scenePathText                    = scenePathLabelText.GetComponent <Text>();
            m_scenePathText.text               = "Scene root:";
            m_scenePathText.fontSize           = 15;
            m_scenePathText.horizontalOverflow = HorizontalWrapMode.Overflow;

            LayoutElement textLayout = scenePathLabelText.gameObject.AddComponent <LayoutElement>();

            textLayout.minWidth       = 210;
            textLayout.flexibleWidth  = 120;
            textLayout.minHeight      = 20;
            textLayout.flexibleHeight = 0;

            m_mainInspectBtn = UIFactory.CreateButton(scenePathGroupObj);
            Text inspectButtonText = m_mainInspectBtn.GetComponentInChildren <Text>();

            inspectButtonText.text = "Inspect";
            LayoutElement inspectButtonLayout = m_mainInspectBtn.AddComponent <LayoutElement>();

            inspectButtonLayout.minWidth      = 65;
            inspectButtonLayout.flexibleWidth = 0;
            Button inspectButton = m_mainInspectBtn.GetComponent <Button>();

            colors               = inspectButton.colors;
            colors.normalColor   = new Color(0.12f, 0.12f, 0.12f);
            inspectButton.colors = colors;

            inspectButton.onClick.AddListener(() => { InspectorManager.Instance.Inspect(m_selectedSceneObject); });

            GameObject scrollObj = UIFactory.CreateScrollView(leftPane, out m_pageContent, out SliderScrollbar scroller, new Color(0.1f, 0.1f, 0.1f));

            m_pageHandler = new PageHandler(scroller);
            m_pageHandler.ConstructUI(leftPane);
            m_pageHandler.OnPageChanged += OnSceneListPageTurn;

            // hide button

            var hideButtonObj = UIFactory.CreateButton(leftPane);
            var hideBtn       = hideButtonObj.GetComponent <Button>();

            var hideColors = hideBtn.colors;

            hideColors.normalColor = new Color(0.15f, 0.15f, 0.15f);
            hideBtn.colors         = hideColors;
            var hideText = hideButtonObj.GetComponentInChildren <Text>();

            hideText.text     = "Hide Scene Explorer";
            hideText.fontSize = 13;
            var hideLayout = hideButtonObj.AddComponent <LayoutElement>();

            hideLayout.minWidth  = 20;
            hideLayout.minHeight = 20;

            hideBtn.onClick.AddListener(OnHide);

            void OnHide()
            {
                if (!Hiding)
                {
                    Hiding = true;

                    hideText.text = "►";
                    titleObj.SetActive(false);
                    sceneDropdownObj.SetActive(false);
                    scenePathGroupObj.SetActive(false);
                    scrollObj.SetActive(false);
                    m_pageHandler.Hide();

                    leftLayout.minWidth = 15;
                }
                else
                {
                    Hiding = false;

                    hideText.text = "Hide Scene Explorer";
                    titleObj.SetActive(true);
                    sceneDropdownObj.SetActive(true);
                    scenePathGroupObj.SetActive(true);
                    scrollObj.SetActive(true);

                    leftLayout.minWidth = 350;

                    Update();
                }

                OnToggleShow?.Invoke();
            }
        }