Skip to content

Commit

Permalink
feat: Add ignore self graphic option.
Browse files Browse the repository at this point in the history
Self Graphic will not be drawn to soft mask buffer.
  • Loading branch information
mob-sakai committed Jun 4, 2020
1 parent a5abcda commit 91c0099
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions Packages/SoftMaskForUGUI/Scripts/SoftMask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ public enum DesamplingRate
[SerializeField, Tooltip("Is the soft mask a part of parent soft mask?")]
private bool m_PartOfParent = false;

[SerializeField, Tooltip("Self Graphic will not be drawn to soft mask buffer.")]
private bool m_IgnoreSelfGraphic;


/// <summary>
/// The desampling rate for soft mask buffer.
Expand Down Expand Up @@ -210,6 +213,19 @@ public SoftMask parent
get { return _parent; }
}

public bool ignoreSelfGraphic
{
get { return m_IgnoreSelfGraphic; }
set
{
if (m_IgnoreSelfGraphic == value) return;
m_IgnoreSelfGraphic = value;
hasChanged = true;
graphic.SetVerticesDirtyEx();
}
}


Material material
{
get
Expand Down Expand Up @@ -263,7 +279,15 @@ void IMeshModifier.ModifyMesh(Mesh mesh)
void IMeshModifier.ModifyMesh(VertexHelper verts)
{
if (isActiveAndEnabled)
{
if (ignoreSelfGraphic)
{
verts.Clear();
}

verts.FillMesh(mesh);
}

hasChanged = true;
}

Expand Down Expand Up @@ -407,6 +431,7 @@ protected override void OnRectTransformDimensionsChange()
/// </summary>
protected override void OnValidate()
{
graphic.SetVerticesDirtyEx();
graphic.SetMaterialDirtyEx();
OnTransformParentChanged();
base.OnValidate();
Expand Down

0 comments on commit 91c0099

Please sign in to comment.