From 3ed20ecaed564c371efa79277a4c5ca4c67efe67 Mon Sep 17 00:00:00 2001 From: Simon Jackson Date: Sat, 24 Dec 2022 13:28:19 +0000 Subject: [PATCH] Updated all components using "LayoutGroup" to override their OnDisable feature to incorporate this fix: https://gist.github.com/randomize/73ca6d3b6aa7210073692eb5cabd537e Resolves: https://github.com/Unity-UI-Extensions/com.unity.uiextensions/issues/178 --- Runtime/Scripts/Layout/CurvedLayout.cs | 7 +++++++ Runtime/Scripts/Layout/FlowLayoutGroup.cs | 10 +++++++++- Runtime/Scripts/Layout/RadialLayout.cs | 7 +++++++ Runtime/Scripts/Layout/TableLayoutGroup.cs | 6 ++++++ 4 files changed, 29 insertions(+), 1 deletion(-) diff --git a/Runtime/Scripts/Layout/CurvedLayout.cs b/Runtime/Scripts/Layout/CurvedLayout.cs index fdc3637..c3fddc2 100644 --- a/Runtime/Scripts/Layout/CurvedLayout.cs +++ b/Runtime/Scripts/Layout/CurvedLayout.cs @@ -29,6 +29,13 @@ namespace UnityEngine.UI.Extensions public float centerpoint = 0.5f; protected override void OnEnable() { base.OnEnable(); CalculateRadial(); } + + protected override void OnDisable() + { + m_Tracker.Clear(); + LayoutRebuilder.MarkLayoutForRebuild(rectTransform); + } + public override void SetLayoutHorizontal() { } public override void SetLayoutVertical() { diff --git a/Runtime/Scripts/Layout/FlowLayoutGroup.cs b/Runtime/Scripts/Layout/FlowLayoutGroup.cs index 86eeb13..1aaccd9 100644 --- a/Runtime/Scripts/Layout/FlowLayoutGroup.cs +++ b/Runtime/Scripts/Layout/FlowLayoutGroup.cs @@ -422,5 +422,13 @@ namespace UnityEngine.UI.Extensions } return max; } - } + + protected override void OnDisable() + { + m_Tracker.Clear(); + LayoutRebuilder.MarkLayoutForRebuild(rectTransform); + } + + + } } \ No newline at end of file diff --git a/Runtime/Scripts/Layout/RadialLayout.cs b/Runtime/Scripts/Layout/RadialLayout.cs index e7b67f8..fb90cb5 100644 --- a/Runtime/Scripts/Layout/RadialLayout.cs +++ b/Runtime/Scripts/Layout/RadialLayout.cs @@ -55,6 +55,13 @@ namespace UnityEngine.UI.Extensions CalculateRadial(); } #endif + + protected override void OnDisable() + { + m_Tracker.Clear(); // key change - do not restore - false + LayoutRebuilder.MarkLayoutForRebuild(rectTransform); + } + void CalculateRadial() { m_Tracker.Clear(); diff --git a/Runtime/Scripts/Layout/TableLayoutGroup.cs b/Runtime/Scripts/Layout/TableLayoutGroup.cs index f5ca4f1..83ade4e 100644 --- a/Runtime/Scripts/Layout/TableLayoutGroup.cs +++ b/Runtime/Scripts/Layout/TableLayoutGroup.cs @@ -284,5 +284,11 @@ namespace UnityEngine.UI.Extensions // Set preferredRowHeights to null to free memory preferredRowHeights = null; } + + protected override void OnDisable() + { + m_Tracker.Clear(); // key change - do not restore - false + LayoutRebuilder.MarkLayoutForRebuild(rectTransform); + } } } \ No newline at end of file