private static void ResizeScrollBar(Panel_CustomXPSetup panel, UIGrid uiGrid)
        {
            UISlider slider      = panel.m_Scrollbar.GetComponentInChildren <UISlider>(true);
            float    viewHeight  = panel.m_ScrollPanel.height;
            float    absoluteVal = slider.value * (panel.m_ScrollPanelHeight - viewHeight);
            int      childCount  = uiGrid.GetChildList().Count;

            float height = childCount * gridCellHeight;

            panel.m_ScrollPanelHeight = height;

            ScrollbarThumbResizer thumbResizer = slider.GetComponent <ScrollbarThumbResizer>();

            thumbResizer.SetNumSteps((int)panel.m_ScrollPanel.height, (int)height);

            slider.value = Mathf.Clamp01(absoluteVal / Mathf.Max(1, panel.m_ScrollPanelHeight - viewHeight));
            panel.OnScrollbarChange();
        }
Beispiel #2
0
        private void ResizeScrollBar(ModTab modTab)
        {
            int childCount = modTab.uiGrid.GetChildList().Count;

            if (modTab == currentTab)
            {
                float absoluteVal = scrollBarSlider.value * modTab.scrollBarHeight;

                float height = childCount * GUIBuilder.gridCellHeight;
                modTab.scrollBarHeight = height - scrollPanel.height;

                ScrollbarThumbResizer thumbResizer = scrollBarSlider.GetComponent <ScrollbarThumbResizer>();
                thumbResizer.SetNumSteps((int)scrollPanel.height, (int)height);

                scrollBarSlider.value = Mathf.Clamp01(absoluteVal / Mathf.Max(1, modTab.scrollBarHeight));
                OnScroll(scrollBarSlider, false);
            }
            else
            {
                modTab.scrollBarHeight = childCount * GUIBuilder.gridCellHeight - scrollPanel.height;
            }

            scrollBar.SetActive(currentTab.scrollBarHeight > 0);
        }