Ejemplo n.º 1
0
        public override void ConstructSubcontent()
        {
            base.ConstructSubcontent();

            m_pageHandler = new PageHandler(null);
            m_pageHandler.ConstructUI(m_subContentParent);
            m_pageHandler.OnPageChanged += OnPageTurned;

            m_listContent = UIFactory.CreateVerticalGroup(this.m_subContentParent, "EnumerableContent", true, true, true, true, 2, new Vector4(5, 5, 5, 5),
                                                          new Color(0.08f, 0.08f, 0.08f));

            var scrollRect = m_listContent.GetComponent <RectTransform>();

            scrollRect.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, 0);

            m_listLayout                = Owner.m_mainContent.GetComponent <LayoutElement>();
            m_listLayout.minHeight      = 25;
            m_listLayout.flexibleHeight = 0;
            Owner.m_mainRect.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, 25);

            var contentFitter = m_listContent.AddComponent <ContentSizeFitter>();

            contentFitter.horizontalFit = ContentSizeFitter.FitMode.Unconstrained;
            contentFitter.verticalFit   = ContentSizeFitter.FitMode.PreferredSize;
        }
Ejemplo n.º 2
0
        internal void ConstructChildList(GameObject parent)
        {
            var vertGroupObj = UIFactory.CreateVerticalGroup(parent, new Color(1, 1, 1, 0));
            var vertGroup    = vertGroupObj.GetComponent <VerticalLayoutGroup>();

            vertGroup.childForceExpandHeight = true;
            vertGroup.childForceExpandWidth  = false;
            vertGroup.childControlWidth      = true;
            vertGroup.spacing = 5;
            var vertLayout = vertGroupObj.AddComponent <LayoutElement>();

            vertLayout.minWidth       = 120;
            vertLayout.flexibleWidth  = 25000;
            vertLayout.minHeight      = 200;
            vertLayout.flexibleHeight = 5000;

            var childTitleObj  = UIFactory.CreateLabel(vertGroupObj, TextAnchor.MiddleLeft);
            var childTitleText = childTitleObj.GetComponent <Text>();

            childTitleText.text     = "Children";
            childTitleText.color    = Color.grey;
            childTitleText.fontSize = 14;
            var childTitleLayout = childTitleObj.AddComponent <LayoutElement>();

            childTitleLayout.minHeight = 30;

            var childrenScrollObj = UIFactory.CreateScrollView(vertGroupObj, out s_childListContent, out SliderScrollbar scroller, new Color(0.07f, 0.07f, 0.07f));
            var contentLayout     = childrenScrollObj.GetComponent <LayoutElement>();

            contentLayout.minHeight = 50;

            s_childListPageHandler = new PageHandler(scroller);
            s_childListPageHandler.ConstructUI(vertGroupObj);
            s_childListPageHandler.OnPageChanged += OnChildListPageTurn;
        }
        public override void ConstructSubcontent()
        {
            base.ConstructSubcontent();

            m_pageHandler = new PageHandler(null);
            m_pageHandler.ConstructUI(m_subContentParent);
            m_pageHandler.OnPageChanged += OnPageTurned;

            var scrollObj = UIFactory.CreateVerticalGroup(this.m_subContentParent, new Color(0.08f, 0.08f, 0.08f));

            m_listContent = scrollObj;

            var scrollRect = scrollObj.GetComponent <RectTransform>();

            scrollRect.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, 0);

            m_listLayout                = Owner.m_mainContent.GetComponent <LayoutElement>();
            m_listLayout.minHeight      = 25;
            m_listLayout.flexibleHeight = 0;
            Owner.m_mainRect.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, 25);

            var scrollGroup = m_listContent.GetComponent <VerticalLayoutGroup>();

            scrollGroup.childForceExpandHeight = true;
            scrollGroup.childControlHeight     = true;
            scrollGroup.spacing        = 2;
            scrollGroup.padding.top    = 5;
            scrollGroup.padding.left   = 5;
            scrollGroup.padding.right  = 5;
            scrollGroup.padding.bottom = 5;

            var contentFitter = scrollObj.AddComponent <ContentSizeFitter>();

            contentFitter.horizontalFit = ContentSizeFitter.FitMode.Unconstrained;
            contentFitter.verticalFit   = ContentSizeFitter.FitMode.PreferredSize;

            ConstructAddRow();

            RefreshElementsAfterUpdate();
        }
Ejemplo n.º 4
0
        internal void ConstructResultsArea()
        {
            // Result group holder (NOT actual result list content)

            var resultGroupObj = UIFactory.CreateVerticalGroup(Content, new Color(1, 1, 1, 0));
            var resultGroup    = resultGroupObj.GetComponent <VerticalLayoutGroup>();

            resultGroup.childForceExpandHeight = false;
            resultGroup.childForceExpandWidth  = true;
            resultGroup.childControlHeight     = true;
            resultGroup.childControlWidth      = true;
            resultGroup.spacing        = 5;
            resultGroup.padding.top    = 5;
            resultGroup.padding.right  = 5;
            resultGroup.padding.left   = 5;
            resultGroup.padding.bottom = 5;

            var resultCountObj = UIFactory.CreateLabel(resultGroupObj, TextAnchor.MiddleCenter);

            m_resultCountText      = resultCountObj.GetComponent <Text>();
            m_resultCountText.text = "No results...";

            GameObject scrollObj = UIFactory.CreateScrollView(resultGroupObj,
                                                              out m_resultListContent,
                                                              out SliderScrollbar scroller,
                                                              new Color(0.07f, 0.07f, 0.07f, 1));

            m_resultListPageHandler = new PageHandler(scroller);
            m_resultListPageHandler.ConstructUI(resultGroupObj);
            m_resultListPageHandler.OnPageChanged += OnResultPageTurn;

            // actual result list content
            var contentGroup = m_resultListContent.GetComponent <VerticalLayoutGroup>();

            contentGroup.spacing = 2;
            contentGroup.childForceExpandHeight = false;
            contentGroup.childControlHeight     = true;
        }
Ejemplo n.º 5
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();
            }
        }