From c2ada36c41bb00a242b59178fdb687e8343ad4c8 Mon Sep 17 00:00:00 2001 From: Simon Jackson Date: Sun, 27 Nov 2022 15:14:52 +0000 Subject: [PATCH] Updated Curly UI to wait until end of the frame to recalculate positions Also updated Editor script to work in 2022 Resolves: - https://github.com/Unity-UI-Extensions/com.unity.uiextensions/issues/409 --- Editor/CUIImageEditor.cs | 5 +++++ Runtime/Scripts/Effects/CurlyUI/CUIGraphic.cs | 8 ++++++++ 2 files changed, 13 insertions(+) diff --git a/Editor/CUIImageEditor.cs b/Editor/CUIImageEditor.cs index c961d07..a3eb6f1 100644 --- a/Editor/CUIImageEditor.cs +++ b/Editor/CUIImageEditor.cs @@ -68,7 +68,12 @@ namespace UnityEngine.UI.Extensions Handles.color = Color.gray; EditorGUI.BeginChangeCheck(); +#if UNITY_2022_1_OR_NEWER + Vector3 newCornerPos = Handles.FreeMoveHandle(script.transform.TransformPoint(cornerPos), HandleUtility.GetHandleSize(script.transform.TransformPoint(cornerPos)) / 7, Vector3.one, Handles.SphereHandleCap); +#else Vector3 newCornerPos = Handles.FreeMoveHandle(script.transform.TransformPoint(cornerPos), script.transform.rotation, HandleUtility.GetHandleSize(script.transform.TransformPoint(cornerPos)) / 7, Vector3.one, Handles.SphereHandleCap); +#endif + Handles.Label(newCornerPos, string.Format("Corner Mover")); newCornerPos = script.transform.InverseTransformPoint(newCornerPos); diff --git a/Runtime/Scripts/Effects/CurlyUI/CUIGraphic.cs b/Runtime/Scripts/Effects/CurlyUI/CUIGraphic.cs index dbdc39b..60cd5f4 100644 --- a/Runtime/Scripts/Effects/CurlyUI/CUIGraphic.cs +++ b/Runtime/Scripts/Effects/CurlyUI/CUIGraphic.cs @@ -1,6 +1,7 @@ /// Credit Titinious (https://github.com/Titinious) /// Sourced from - https://github.com/Titinious/CurlyUI +using System.Collections; using System.Collections.Generic; #if UNITY_EDITOR @@ -286,6 +287,13 @@ namespace UnityEngine.UI.Extensions public void Refresh() { + StartCoroutine(RefreshOnNextFrame()); + } + + public IEnumerator RefreshOnNextFrame() + { + yield return new WaitForEndOfFrame(); + ReportSet(); // we use local position as the true value. Ratio position follows it, so it should be updated when refresh