void ClickModule(ChartModule selectedModule) { foreach (var module in m_ChartModule) { if (selectedModule != module) { var block = module.button.colors; block.highlightedColor = m_ButtonHighlightColor; block.normalColor = m_ButtonNormalColor; module.button.colors = block; module.panel.SetActive(false); module.select = false; } else { var block = module.button.colors; block.highlightedColor = m_ButtonSelectedColor; block.normalColor = m_ButtonSelectedColor; module.button.colors = block; module.panel.SetActive(true); module.select = true; } } m_ScrollRect.content = selectedModule.panel.GetComponent <RectTransform>(); m_Title.text = string.IsNullOrEmpty(selectedModule.title) ? selectedModule.name : selectedModule.title; }
private void SetChartRootInfo(ChartModule module) { var chartRoot = module.panel; var grid = chartRoot.GetComponent <GridLayoutGroup>(); var hig = Mathf.CeilToInt(chartRoot.transform.childCount * 1f / module.column) * (grid.cellSize.y + grid.spacing.y); SetChartGridLayoutGroup(grid, module.column); UIUtil.SetRectTransformHeight(chartRoot.transform, hig); }
void ClickModule(ChartModule selectedModule) { if (lastSelectedModuleIndex >= 0) { m_ChartModule[lastSelectedModuleIndex].select = false; } lastSelectedModuleIndex = selectedModule.index; foreach (var module in m_ChartModule) { if (module.index != lastSelectedModuleIndex) { var block = module.button.colors; block.highlightedColor = m_ButtonHighlightColor; #if UNITY_2019 block.selectedColor = m_ButtonNormalColor; #endif block.pressedColor = m_ButtonNormalColor; block.normalColor = m_ButtonNormalColor; module.button.colors = block; if (module.panel != null) { module.panel.SetActive(false); } } else { var block = module.button.colors; block.highlightedColor = m_ButtonSelectedColor; #if UNITY_2019 block.selectedColor = m_ButtonSelectedColor; #endif block.pressedColor = m_ButtonSelectedColor; block.normalColor = m_ButtonSelectedColor; module.button.colors = block; if (module.panel != null) { module.panel.SetActive(true); } } } if (selectedModule.panel != null) { m_ScrollRect.content = selectedModule.panel.GetComponent <RectTransform>(); } SetChartRootInfo(selectedModule); m_Title.text = string.IsNullOrEmpty(selectedModule.title) ? selectedModule.name : selectedModule.title; }