diff options
author | chai <chaifix@163.com> | 2021-04-26 21:16:23 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2021-04-26 21:16:23 +0800 |
commit | 83eb6c0dc5773c40b5ee4d9b2fb1d72a7d5294f5 (patch) | |
tree | f8be10f80451f730529d66ecef7cad0c40e3505c /Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Layout | |
parent | d4e02e80388649a184bc6eb247e035102eb3c81d (diff) |
*misc
Diffstat (limited to 'Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Layout')
-rw-r--r-- | Assets/uGUI-2017.1/UnityEngine.UI/UI/Core/Layout/LayoutRebuilder.cs | 10 |
1 files changed, 6 insertions, 4 deletions
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 da201a7..6edd5b5 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 @@ -7,7 +7,7 @@ namespace UnityEngine.UI { // m_ToRebuild是一个ILayoutGroup private RectTransform m_ToRebuild; - //There are a few of reasons we need to cache the Hash fromt he transform: + //There are a few of reasons we need to cache the Hash from the transform: // - This is a ValueType (struct) and .Net calculates Hash from the Value Type fields. // - The key of a Dictionary should have a constant Hash value. // - It's possible for the Transform to get nulled from the Native side. @@ -15,6 +15,7 @@ namespace UnityEngine.UI // So this struct gets used as a key to a dictionary, so we need to guarantee a constant Hash value. private int m_CachedHashFromTransform; + // 一个rebuilder结构的池子 static ObjectPool<LayoutRebuilder> s_Rebuilders = new ObjectPool<LayoutRebuilder>(null, x => x.Clear()); private void Initialize(RectTransform controller) @@ -141,13 +142,14 @@ namespace UnityEngine.UI ListPool<Component>.Release(components); } + // 找到rect祖先节点中的layoutGroup并加入队列 public static void MarkLayoutForRebuild(RectTransform rect) { if (rect == null) return; var comps = ListPool<Component>.Get(); - RectTransform layoutRoot = rect; + RectTransform layoutRoot = rect; // 祖先节点中的layoutGroup while (true) { var parent = layoutRoot.parent as RectTransform; @@ -183,7 +185,6 @@ namespace UnityEngine.UI { if (layoutRoot == null) return false; - layoutRoot.GetComponents(typeof(ILayoutController), comps); StripDisabledBehavioursFromList(comps); var valid = comps.Count > 0; @@ -197,13 +198,14 @@ namespace UnityEngine.UI var rebuilder = s_Rebuilders.Get(); rebuilder.Initialize(controller); - // 注册进去 + // 注册到CanvasUpdateRegistry里 if (!CanvasUpdateRegistry.TryRegisterCanvasElementForLayoutRebuild(rebuilder)) s_Rebuilders.Release(rebuilder); } public void LayoutComplete() { + // 放回池子里 s_Rebuilders.Release(this); } |