From c710787b5ba496cf73e7eb43458bb3958139baa9 Mon Sep 17 00:00:00 2001 From: mob-sakai Date: Wed, 8 Nov 2023 11:52:31 +0900 Subject: [PATCH] feat: reset transform.localScale on upgrading v3.x to v4.x close #277 --- Scripts/UIParticle.cs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/Scripts/UIParticle.cs b/Scripts/UIParticle.cs index b27740a..82b6960 100644 --- a/Scripts/UIParticle.cs +++ b/Scripts/UIParticle.cs @@ -100,6 +100,9 @@ namespace Coffee.UIExtensions "UIParticle: UIParticle.scale will be adjusted.")] private AutoScalingMode m_AutoScalingMode = AutoScalingMode.Transform; + [SerializeField] + private bool m_ResetScaleOnEnable; + private readonly List _renderers = new List(); private int _groupId; private Camera _orthoCamera; @@ -322,6 +325,13 @@ namespace Coffee.UIExtensions } base.OnEnable(); + + // Reset scale for upgrade. + if (m_ResetScaleOnEnable) + { + m_ResetScaleOnEnable = false; + transform.localScale = Vector3.one; + } } /// @@ -363,6 +373,17 @@ namespace Coffee.UIExtensions m_IgnoreCanvasScaler = false; m_AutoScaling = false; m_AutoScalingMode = AutoScalingMode.Transform; + m_ResetScaleOnEnable = true; + +#if UNITY_EDITOR + EditorApplication.delayCall += () => + { + if (!this || !gameObject || !transform) return; + transform.localScale = Vector3.one; + m_ResetScaleOnEnable = false; + EditorUtility.SetDirty(this); + }; +#endif } if (m_AbsoluteMode)