feat: Add ignore self graphic option.

Self Graphic will not be drawn to soft mask buffer.
vr
mob-sakai 2020-06-04 10:35:30 +09:00
parent a5abcdaa20
commit 91c00993b9
1 changed files with 25 additions and 0 deletions

View File

@ -82,6 +82,9 @@ namespace Coffee.UISoftMask
[SerializeField, Tooltip("Is the soft mask a part of parent soft mask?")] [SerializeField, Tooltip("Is the soft mask a part of parent soft mask?")]
private bool m_PartOfParent = false; private bool m_PartOfParent = false;
[SerializeField, Tooltip("Self Graphic will not be drawn to soft mask buffer.")]
private bool m_IgnoreSelfGraphic;
/// <summary> /// <summary>
/// The desampling rate for soft mask buffer. /// The desampling rate for soft mask buffer.
@ -210,6 +213,19 @@ namespace Coffee.UISoftMask
get { return _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 Material material
{ {
get get
@ -263,7 +279,15 @@ namespace Coffee.UISoftMask
void IMeshModifier.ModifyMesh(VertexHelper verts) void IMeshModifier.ModifyMesh(VertexHelper verts)
{ {
if (isActiveAndEnabled) if (isActiveAndEnabled)
{
if (ignoreSelfGraphic)
{
verts.Clear();
}
verts.FillMesh(mesh); verts.FillMesh(mesh);
}
hasChanged = true; hasChanged = true;
} }
@ -407,6 +431,7 @@ namespace Coffee.UISoftMask
/// </summary> /// </summary>
protected override void OnValidate() protected override void OnValidate()
{ {
graphic.SetVerticesDirtyEx();
graphic.SetMaterialDirtyEx(); graphic.SetMaterialDirtyEx();
OnTransformParentChanged(); OnTransformParentChanged();
base.OnValidate(); base.OnValidate();