From 28b115329e4cbd45df061c80aebce6f06ebda359 Mon Sep 17 00:00:00 2001 From: mob-sakai Date: Tue, 21 Sep 2021 16:11:48 +0900 Subject: [PATCH] feat: remove `IgnoreCanvasScaler` option close #156 BREAKING CHANGE: This option is no longer needed. --- Scripts/Editor/UIParticleEditor.cs | 15 --------------- Scripts/UIParticle.cs | 23 ----------------------- Scripts/UIParticleUpdater.cs | 22 ---------------------- 3 files changed, 60 deletions(-) diff --git a/Scripts/Editor/UIParticleEditor.cs b/Scripts/Editor/UIParticleEditor.cs index 2187460..192167d 100644 --- a/Scripts/Editor/UIParticleEditor.cs +++ b/Scripts/Editor/UIParticleEditor.cs @@ -25,7 +25,6 @@ namespace Coffee.UIExtensions private SerializedProperty _spMaskable; private SerializedProperty _spScale; - private SerializedProperty _spIgnoreCanvasScaler; private SerializedProperty _spAnimatableProperties; private SerializedProperty _spShrinkByMaterial; @@ -55,7 +54,6 @@ namespace Coffee.UIExtensions base.OnEnable(); _spMaskable = serializedObject.FindProperty("m_Maskable"); _spScale = serializedObject.FindProperty("m_Scale3D"); - _spIgnoreCanvasScaler = serializedObject.FindProperty("m_IgnoreCanvasScaler"); _spAnimatableProperties = serializedObject.FindProperty("m_AnimatableProperties"); _spShrinkByMaterial = serializedObject.FindProperty("m_ShrinkByMaterial"); _showMaterials = EditorPrefs.GetBool("Coffee.UIExtensions.UIParticleEditor._showMaterials", true); @@ -138,19 +136,6 @@ namespace Coffee.UIExtensions // Maskable EditorGUILayout.PropertyField(_spMaskable); - // IgnoreCanvasScaler - using (var ccs = new EditorGUI.ChangeCheckScope()) - { - EditorGUILayout.PropertyField(_spIgnoreCanvasScaler); - if (ccs.changed) - { - foreach (UIParticle p in targets) - { - p.ignoreCanvasScaler = _spIgnoreCanvasScaler.boolValue; - } - } - } - // Scale _xyzMode = DrawFloatOrVector3Field(_spScale, _xyzMode); diff --git a/Scripts/UIParticle.cs b/Scripts/UIParticle.cs index 94e0dd3..c64b629 100755 --- a/Scripts/UIParticle.cs +++ b/Scripts/UIParticle.cs @@ -27,9 +27,6 @@ namespace Coffee.UIExtensions { [HideInInspector] [SerializeField] internal bool m_IsTrail = false; - [Tooltip("Ignore canvas scaler")] [SerializeField] [FormerlySerializedAs("m_IgnoreParent")] - bool m_IgnoreCanvasScaler = true; - [Tooltip("Particle effect scale")] [SerializeField] float m_Scale = 100; @@ -50,7 +47,6 @@ namespace Coffee.UIExtensions #endif private bool _shouldBeRemoved; - private DrivenRectTransformTracker _tracker; private Mesh _bakedMesh; private readonly List _modifiedMaterials = new List(); private readonly List _maskMaterials = new List(); @@ -73,19 +69,6 @@ namespace Coffee.UIExtensions set { } } - public bool ignoreCanvasScaler - { - get { return m_IgnoreCanvasScaler; } - set - { - // if (m_IgnoreCanvasScaler == value) return; - m_IgnoreCanvasScaler = value; - _tracker.Clear(); - if (isActiveAndEnabled && m_IgnoreCanvasScaler) - _tracker.Add(this, rectTransform, DrivenTransformProperties.Scale); - } - } - public bool shrinkByMaterial { get { return m_ShrinkByMaterial; } @@ -400,11 +383,6 @@ namespace Coffee.UIExtensions UIParticleUpdater.Register(this); particles.Exec(p => p.GetComponent().enabled = false); - if (isActiveAndEnabled && m_IgnoreCanvasScaler) - { - _tracker.Add(this, rectTransform, DrivenTransformProperties.Scale); - } - // Create objects. _bakedMesh = MeshPool.Rent(); @@ -440,7 +418,6 @@ namespace Coffee.UIExtensions UIParticleUpdater.Unregister(this); if (!_shouldBeRemoved) particles.Exec(p => p.GetComponent().enabled = true); - _tracker.Clear(); // Destroy object. MeshPool.Return(_bakedMesh); diff --git a/Scripts/UIParticleUpdater.cs b/Scripts/UIParticleUpdater.cs index 129965e..9d412dd 100755 --- a/Scripts/UIParticleUpdater.cs +++ b/Scripts/UIParticleUpdater.cs @@ -66,10 +66,6 @@ namespace Coffee.UIExtensions { if (!particle || !particle.bakedMesh || !particle.canvas || !particle.canvasRenderer) return; - Profiler.BeginSample("[UIParticle] Modify scale"); - ModifyScale(particle); - Profiler.EndSample(); - Profiler.BeginSample("[UIParticle] Bake mesh"); BakeMesh(particle); Profiler.EndSample(); @@ -90,24 +86,6 @@ namespace Coffee.UIExtensions Profiler.EndSample(); } - private static void ModifyScale(UIParticle particle) - { - if (!particle.ignoreCanvasScaler || !particle.canvas) return; - - // Ignore Canvas scaling. - var s = particle.canvas.rootCanvas.transform.localScale; - var modifiedScale = new Vector3( - Mathf.Approximately(s.x, 0) ? 1 : 1 / s.x, - Mathf.Approximately(s.y, 0) ? 1 : 1 / s.y, - Mathf.Approximately(s.z, 0) ? 1 : 1 / s.z); - - // Scale is already modified. - var transform = particle.transform; - if (Mathf.Approximately((transform.localScale - modifiedScale).sqrMagnitude, 0)) return; - - transform.localScale = modifiedScale; - } - private static Matrix4x4 GetScaledMatrix(ParticleSystem particle) { var transform = particle.transform;