From c3979444c23fb831ebd2be4ec8829b691ee71474 Mon Sep 17 00:00:00 2001 From: chai Date: Tue, 27 Apr 2021 17:01:41 +0800 Subject: *layout --- Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Layout/LayoutGroup.cs | 9 +++++---- .../uGUI-2017.1/UnityEngine.UI/UI/Core/Layout/LayoutRebuilder.cs | 3 +++ 2 files changed, 8 insertions(+), 4 deletions(-) (limited to 'Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Layout') 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 m_RectChildren = new List(); - protected List rectChildren { get { return m_RectChildren; } } - - // ILayoutElement Interface + protected List rectChildren { get { return m_RectChildren; } } + + + // ILayoutElement Interface + // 收集子节点中参与布局的节点 public virtual void CalculateLayoutInputHorizontal() { - // 收集子节点中参与layout的节点 m_RectChildren.Clear(); var toIgnoreList = ListPool.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 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) -- cgit v1.1-26-g67d0