feat: add a new option to ignore stencil if it is not needed as a mask
parent
f38f034148
commit
9edcb2d22b
|
@ -86,6 +86,9 @@ namespace Coffee.UISoftMask
|
||||||
private bool m_IgnoreSelfGraphic;
|
private bool m_IgnoreSelfGraphic;
|
||||||
|
|
||||||
|
|
||||||
|
[SerializeField, Tooltip("Self graphic will not be written to stencil buffer.")]
|
||||||
|
private bool m_IgnoreSelfStencil;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The desampling rate for soft mask buffer.
|
/// The desampling rate for soft mask buffer.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -225,6 +228,20 @@ namespace Coffee.UISoftMask
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool ignoreSelfStencil
|
||||||
|
{
|
||||||
|
get { return m_IgnoreSelfStencil; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (m_IgnoreSelfStencil == value) return;
|
||||||
|
m_IgnoreSelfStencil = value;
|
||||||
|
hasChanged = true;
|
||||||
|
graphic.SetVerticesDirtyEx();
|
||||||
|
graphic.SetMaterialDirtyEx();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Material material
|
Material material
|
||||||
{
|
{
|
||||||
|
@ -254,6 +271,8 @@ namespace Coffee.UISoftMask
|
||||||
public override Material GetModifiedMaterial(Material baseMaterial)
|
public override Material GetModifiedMaterial(Material baseMaterial)
|
||||||
{
|
{
|
||||||
hasChanged = true;
|
hasChanged = true;
|
||||||
|
if (ignoreSelfStencil) return baseMaterial;
|
||||||
|
|
||||||
var result = base.GetModifiedMaterial(baseMaterial);
|
var result = base.GetModifiedMaterial(baseMaterial);
|
||||||
if (m_IgnoreParent && result != baseMaterial)
|
if (m_IgnoreParent && result != baseMaterial)
|
||||||
{
|
{
|
||||||
|
@ -283,9 +302,17 @@ namespace Coffee.UISoftMask
|
||||||
if (ignoreSelfGraphic)
|
if (ignoreSelfGraphic)
|
||||||
{
|
{
|
||||||
verts.Clear();
|
verts.Clear();
|
||||||
|
verts.FillMesh(mesh);
|
||||||
|
}
|
||||||
|
else if (ignoreSelfStencil)
|
||||||
|
{
|
||||||
|
verts.FillMesh(mesh);
|
||||||
|
verts.Clear();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
verts.FillMesh(mesh);
|
||||||
}
|
}
|
||||||
|
|
||||||
verts.FillMesh(mesh);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
hasChanged = true;
|
hasChanged = true;
|
||||||
|
|
Loading…
Reference in New Issue