From cf4fab04c50830fb29534f0c018366708ad51c72 Mon Sep 17 00:00:00 2001
From: client_Hale <339726288@qq.com>
Date: 星期五, 19 四月 2019 21:35:10 +0800
Subject: [PATCH] Merge branch 'master' of http://192.168.0.87:10010/r/snxxz_scripts
---
System/MainWin/HighSettingFadeInFadeOut.cs | 91 +++++++++++++++++++++++++++++++--------------
1 files changed, 62 insertions(+), 29 deletions(-)
diff --git a/System/MainWin/HighSettingFadeInFadeOut.cs b/System/MainWin/HighSettingFadeInFadeOut.cs
index 95a818b..64e61ea 100644
--- a/System/MainWin/HighSettingFadeInFadeOut.cs
+++ b/System/MainWin/HighSettingFadeInFadeOut.cs
@@ -17,8 +17,14 @@
[SerializeField] Image m_ArrowOpen;
[SerializeField] Image m_ArrowClose;
+ [SerializeField] Vector2 m_GridSize;
+ [SerializeField] Vector2 m_Space;
+
[SerializeField] MainWinTopGrid[] m_GridGroup1;
[SerializeField] MainWinTopGrid[] m_GridGroup2;
+
+ [SerializeField] RectTransform m_GroupContainer1;
+ [SerializeField] RectTransform m_GroupContainer2;
State state = State.Closed;
@@ -90,7 +96,7 @@
{
if (!grid.alwayShow)
{
- grid.Switch(active, (index / 7) + 1);
+ grid.Switch(active, (index / 6) + 1);
}
if (grid.gameObject.activeInHierarchy)
@@ -122,7 +128,7 @@
{
if (!grid.alwayShow)
{
- grid.SwitchImmediately(active, (index / 7) + 1);
+ grid.SwitchImmediately(active, (index / 6) + 1);
}
if (grid.gameObject.activeInHierarchy)
@@ -203,33 +209,10 @@
private void RefreshGridsActiveState()
{
- foreach (var grid in m_GridGroup1)
- {
- var active = grid.IsOpen();
- if (active && !grid.gameObject.activeSelf)
- {
- grid.gameObject.SetActive(true);
- }
-
- if (!active && grid.gameObject.activeSelf)
- {
- grid.gameObject.SetActive(false);
- }
- }
-
- foreach (var grid in m_GridGroup2)
- {
- var active = grid.IsOpen();
- if (active && !grid.gameObject.activeSelf)
- {
- grid.gameObject.SetActive(true);
- }
-
- if (!active && grid.gameObject.activeSelf)
- {
- grid.gameObject.SetActive(false);
- }
- }
+ ActiveGroup(m_GridGroup1);
+ ActiveGroup(m_GridGroup2);
+ LayoutGroup(m_GridGroup1, m_GroupContainer1);
+ LayoutGroup(m_GridGroup2, m_GroupContainer2);
m_Switch.gameObject.SetActive(IsShowButton());
}
@@ -276,6 +259,56 @@
m_ArrowClose.gameObject.SetActive(state == State.Closed);
}
+ void ActiveGroup(MainWinTopGrid[] grids)
+ {
+ foreach (var grid in grids)
+ {
+ var active = grid.IsOpen();
+ if (active && !grid.gameObject.activeSelf)
+ {
+ grid.gameObject.SetActive(true);
+ }
+
+ if (!active && grid.gameObject.activeSelf)
+ {
+ grid.gameObject.SetActive(false);
+ }
+ }
+ }
+
+ void LayoutGroup(MainWinTopGrid[] grids, RectTransform container)
+ {
+ var index = 0;
+ foreach (var grid in grids)
+ {
+ if (grid.gameObject.activeSelf)
+ {
+ var row = index / 6;
+ var column = index % 6;
+
+ var x = container.rect.width * 0.5f - m_GridSize.x * (column + 0.5f) - m_Space.x * column;
+ var y = container.rect.height * 0.5f - m_GridSize.y * (row + 0.5f) - m_Space.y * row;
+ grid.rectTransform.anchoredPosition = new Vector2(x, y);
+ index++;
+ }
+ }
+
+ foreach (var grid in grids)
+ {
+ if (grid.gameObject.activeSelf)
+ {
+ grid.transform.SetAsFirstSibling();
+ }
+ }
+ }
+
+ [ContextMenu("Layout")]
+ public void LayoutGroup()
+ {
+ LayoutGroup(m_GridGroup1, m_GroupContainer1);
+ LayoutGroup(m_GridGroup2, m_GroupContainer2);
+ }
+
public enum State
{
Opened,
--
Gitblit v1.8.0