From af5f7e90b0570d5c7fcf045fd6b81036a060e493 Mon Sep 17 00:00:00 2001 From: mob-sakai Date: Wed, 28 Oct 2020 22:19:15 +0900 Subject: [PATCH] feat: maskable option to ignore masking Close #109 --- Scripts/Editor/UIParticleEditor.cs | 5 +++++ Scripts/UIParticle.cs | 11 +++++++++++ 2 files changed, 16 insertions(+) diff --git a/Scripts/Editor/UIParticleEditor.cs b/Scripts/Editor/UIParticleEditor.cs index cc4ce86..62cd226 100644 --- a/Scripts/Editor/UIParticleEditor.cs +++ b/Scripts/Editor/UIParticleEditor.cs @@ -25,6 +25,7 @@ internal class UIParticleEditor : GraphicEditor private static readonly List s_TempParents = new List(); private static readonly List s_TempChildren = new List(); + private SerializedProperty _spMaskable; private SerializedProperty _spScale; private SerializedProperty _spIgnoreCanvasScaler; private SerializedProperty _spAnimatableProperties; @@ -52,6 +53,7 @@ internal class UIParticleEditor : GraphicEditor protected override void OnEnable() { base.OnEnable(); + _spMaskable = serializedObject.FindProperty("m_Maskable"); _spScale = serializedObject.FindProperty("m_Scale3D"); _spIgnoreCanvasScaler = serializedObject.FindProperty("m_IgnoreCanvasScaler"); _spAnimatableProperties = serializedObject.FindProperty("m_AnimatableProperties"); @@ -127,6 +129,9 @@ public override void OnInspectorGUI() serializedObject.Update(); + // Maskable + EditorGUILayout.PropertyField(_spMaskable); + // IgnoreCanvasScaler using (var ccs = new EditorGUI.ChangeCheckScope()) { diff --git a/Scripts/UIParticle.cs b/Scripts/UIParticle.cs index edf24b5..2fe0bb3 100755 --- a/Scripts/UIParticle.cs +++ b/Scripts/UIParticle.cs @@ -38,6 +38,11 @@ public class UIParticle : MaskableGraphic [Tooltip("Particles")] [SerializeField] private List m_Particles = new List(); +#if !UNITY_2019_4_OR_NEWER + [SerializeField] + private bool m_Maskable = true; +#endif + private bool _shouldBeRemoved; private DrivenRectTransformTracker _tracker; private Mesh _bakedMesh; @@ -350,6 +355,9 @@ internal void UpdateMaterialProperties(Renderer r, int index) /// protected override void OnEnable() { +#if !UNITY_2019_4_OR_NEWER + maskable = m_Maskable; +#endif _cachedPosition = transform.localPosition; activeMeshIndices.Clear(); @@ -440,6 +448,9 @@ protected override void OnValidate() SetVerticesDirty(); m_ShouldRecalculateStencil = true; RecalculateClipping(); +#if !UNITY_2019_4_OR_NEWER + maskable = m_Maskable; +#endif } void ISerializationCallbackReceiver.OnBeforeSerialize()