Skip to content

Commit

Permalink
feat: maskable option to ignore masking
Browse files Browse the repository at this point in the history
Close #109
  • Loading branch information
mob-sakai committed Oct 28, 2020
1 parent 3d8f11b commit af5f7e9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Scripts/Editor/UIParticleEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ internal class UIParticleEditor : GraphicEditor
private static readonly List<UIParticle> s_TempParents = new List<UIParticle>();
private static readonly List<UIParticle> s_TempChildren = new List<UIParticle>();

private SerializedProperty _spMaskable;
private SerializedProperty _spScale;
private SerializedProperty _spIgnoreCanvasScaler;
private SerializedProperty _spAnimatableProperties;
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -127,6 +129,9 @@ public override void OnInspectorGUI()

serializedObject.Update();

// Maskable
EditorGUILayout.PropertyField(_spMaskable);

// IgnoreCanvasScaler
using (var ccs = new EditorGUI.ChangeCheckScope())
{
Expand Down
11 changes: 11 additions & 0 deletions Scripts/UIParticle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ public class UIParticle : MaskableGraphic
[Tooltip("Particles")] [SerializeField]
private List<ParticleSystem> m_Particles = new List<ParticleSystem>();

#if !UNITY_2019_4_OR_NEWER
[SerializeField]
private bool m_Maskable = true;
#endif

private bool _shouldBeRemoved;
private DrivenRectTransformTracker _tracker;
private Mesh _bakedMesh;
Expand Down Expand Up @@ -350,6 +355,9 @@ internal void UpdateMaterialProperties(Renderer r, int index)
/// </summary>
protected override void OnEnable()
{
#if !UNITY_2019_4_OR_NEWER
maskable = m_Maskable;
#endif
_cachedPosition = transform.localPosition;
activeMeshIndices.Clear();

Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit af5f7e9

Please sign in to comment.