Skip to content

Commit

Permalink
feat: reset transform.localScale on upgrading v3.x to v4.x
Browse files Browse the repository at this point in the history
close #277
  • Loading branch information
mob-sakai committed Nov 8, 2023
1 parent 107f901 commit c710787
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions Scripts/UIParticle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ public enum AutoScalingMode
"UIParticle: UIParticle.scale will be adjusted.")]
private AutoScalingMode m_AutoScalingMode = AutoScalingMode.Transform;

[SerializeField]
private bool m_ResetScaleOnEnable;

private readonly List<UIParticleRenderer> _renderers = new List<UIParticleRenderer>();
private int _groupId;
private Camera _orthoCamera;
Expand Down Expand Up @@ -322,6 +325,13 @@ protected override void OnEnable()
}

base.OnEnable();

// Reset scale for upgrade.
if (m_ResetScaleOnEnable)
{
m_ResetScaleOnEnable = false;
transform.localScale = Vector3.one;
}
}

/// <summary>
Expand Down Expand Up @@ -363,6 +373,17 @@ void ISerializationCallbackReceiver.OnAfterDeserialize()
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)
Expand Down

0 comments on commit c710787

Please sign in to comment.