feat: reset transform.localScale on upgrading v3.x to v4.x

close #277
pull/289/head
mob-sakai 2023-11-08 11:52:31 +09:00
parent 107f901fe3
commit c710787b5b
1 changed files with 21 additions and 0 deletions

View File

@ -100,6 +100,9 @@ namespace Coffee.UIExtensions
"UIParticle: UIParticle.scale will be adjusted.")] "UIParticle: UIParticle.scale will be adjusted.")]
private AutoScalingMode m_AutoScalingMode = AutoScalingMode.Transform; private AutoScalingMode m_AutoScalingMode = AutoScalingMode.Transform;
[SerializeField]
private bool m_ResetScaleOnEnable;
private readonly List<UIParticleRenderer> _renderers = new List<UIParticleRenderer>(); private readonly List<UIParticleRenderer> _renderers = new List<UIParticleRenderer>();
private int _groupId; private int _groupId;
private Camera _orthoCamera; private Camera _orthoCamera;
@ -322,6 +325,13 @@ namespace Coffee.UIExtensions
} }
base.OnEnable(); base.OnEnable();
// Reset scale for upgrade.
if (m_ResetScaleOnEnable)
{
m_ResetScaleOnEnable = false;
transform.localScale = Vector3.one;
}
} }
/// <summary> /// <summary>
@ -363,6 +373,17 @@ namespace Coffee.UIExtensions
m_IgnoreCanvasScaler = false; m_IgnoreCanvasScaler = false;
m_AutoScaling = false; m_AutoScaling = false;
m_AutoScalingMode = AutoScalingMode.Transform; 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) if (m_AbsoluteMode)