summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Assets/Test/06_Layout/06_Layout.unity12
-rw-r--r--Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Layout/LayoutGroup.cs9
-rw-r--r--Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Layout/LayoutRebuilder.cs3
3 files changed, 14 insertions, 10 deletions
diff --git a/Assets/Test/06_Layout/06_Layout.unity b/Assets/Test/06_Layout/06_Layout.unity
index 1a3995c..76f31f4 100644
--- a/Assets/Test/06_Layout/06_Layout.unity
+++ b/Assets/Test/06_Layout/06_Layout.unity
@@ -303,8 +303,8 @@ MonoBehaviour:
m_MinHeight: 32
m_PreferredWidth: 64
m_PreferredHeight: 64
- m_FlexibleWidth: -1
- m_FlexibleHeight: -1
+ m_FlexibleWidth: 3
+ m_FlexibleHeight: 1
m_LayoutPriority: 1
--- !u!1 &957653075
GameObject:
@@ -391,8 +391,8 @@ MonoBehaviour:
m_MinHeight: 40
m_PreferredWidth: 50
m_PreferredHeight: 50
- m_FlexibleWidth: -1
- m_FlexibleHeight: -1
+ m_FlexibleWidth: 1
+ m_FlexibleHeight: 1
m_LayoutPriority: 1
--- !u!1 &1341807674
GameObject:
@@ -533,8 +533,8 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
- m_AnchoredPosition: {x: -625.22, y: 400.61}
- m_SizeDelta: {x: 290.15, y: 190.48}
+ m_AnchoredPosition: {x: -590.23, y: 362.81}
+ m_SizeDelta: {x: 360.13, y: 266.09}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1447362005
MonoBehaviour:
diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Layout/LayoutGroup.cs b/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Layout/LayoutGroup.cs
index 59d432c..6a17e00 100644
--- a/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Layout/LayoutGroup.cs
+++ b/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Layout/LayoutGroup.cs
@@ -34,12 +34,13 @@ namespace UnityEngine.UI
private Vector2 m_TotalFlexibleSize = Vector2.zero;
[System.NonSerialized] private List<RectTransform> m_RectChildren = new List<RectTransform>();
- protected List<RectTransform> rectChildren { get { return m_RectChildren; } }
-
- // ILayoutElement Interface
+ protected List<RectTransform> rectChildren { get { return m_RectChildren; } }
+
+
+ // ILayoutElement Interface
+ // 收集子节点中参与布局的节点
public virtual void CalculateLayoutInputHorizontal()
{
- // 收集子节点中参与layout的节点
m_RectChildren.Clear();
var toIgnoreList = ListPool<Component>.Get();
for (int i = 0; i < rectTransform.childCount; i++)
diff --git a/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Layout/LayoutRebuilder.cs b/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Layout/LayoutRebuilder.cs
index 6edd5b5..5fba1cc 100644
--- a/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Layout/LayoutRebuilder.cs
+++ b/Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Layout/LayoutRebuilder.cs
@@ -78,6 +78,7 @@ namespace UnityEngine.UI
}
}
+ // 从上到下遍历,执行action
private void PerformLayoutControl(RectTransform rect, UnityAction<Component> action)
{
if (rect == null)
@@ -96,6 +97,8 @@ namespace UnityEngine.UI
// Layout control needs to executed top down with parents being done before their children,
// because the children rely on the sizes of the parents.
+ // 做两次遍历,先执行ILayoutSelfController比如ContentSizeFitter,再执行ILayoutGroup
+
// First call layout controllers that may change their own RectTransform
for (int i = 0; i < components.Count; i++)
if (components[i] is ILayoutSelfController)