parent
187ad40b73
commit
3b427274c9
|
@ -262,8 +262,8 @@ namespace Coffee.UIExtensions
|
||||||
|
|
||||||
int x = (int)((softMaskBuffer.width - 1) * Mathf.Clamp01(sp.x / Screen.width));
|
int x = (int)((softMaskBuffer.width - 1) * Mathf.Clamp01(sp.x / Screen.width));
|
||||||
int y = s_UVStartsAtTop
|
int y = s_UVStartsAtTop
|
||||||
? (int)((softMaskBuffer.height - 1) * Mathf.Clamp01(sp.y / Screen.height))
|
? (int)((softMaskBuffer.height - 1) * (1 - Mathf.Clamp01(sp.y / Screen.height)))
|
||||||
: (int)((softMaskBuffer.height - 1) * (1 - Mathf.Clamp01(sp.y / Screen.height)));
|
: (int)((softMaskBuffer.height - 1) * Mathf.Clamp01(sp.y / Screen.height));
|
||||||
return 0.5f < GetPixelValue(x, y, interactions);
|
return 0.5f < GetPixelValue(x, y, interactions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -286,11 +286,11 @@ namespace Coffee.UIExtensions
|
||||||
// Register.
|
// Register.
|
||||||
if (s_ActiveSoftMasks.Count == 0)
|
if (s_ActiveSoftMasks.Count == 0)
|
||||||
{
|
{
|
||||||
s_UVStartsAtTop = SystemInfo.graphicsUVStartsAtTop;
|
|
||||||
Canvas.willRenderCanvases += UpdateMaskTextures;
|
Canvas.willRenderCanvases += UpdateMaskTextures;
|
||||||
|
|
||||||
if (s_StencilCompId == 0)
|
if (s_StencilCompId == 0)
|
||||||
{
|
{
|
||||||
|
s_UVStartsAtTop = SystemInfo.graphicsUVStartsAtTop;
|
||||||
s_StencilCompId = Shader.PropertyToID("_StencilComp");
|
s_StencilCompId = Shader.PropertyToID("_StencilComp");
|
||||||
s_ColorMaskId = Shader.PropertyToID("_ColorMask");
|
s_ColorMaskId = Shader.PropertyToID("_ColorMask");
|
||||||
s_MainTexId = Shader.PropertyToID("_MainTex");
|
s_MainTexId = Shader.PropertyToID("_MainTex");
|
||||||
|
|
|
@ -36,8 +36,10 @@ namespace Coffee.UIExtensions
|
||||||
[Tooltip("The interaction for each masks.")]
|
[Tooltip("The interaction for each masks.")]
|
||||||
[HideInInspector]
|
[HideInInspector]
|
||||||
[SerializeField] int m_MaskInteraction = kVisibleInside;
|
[SerializeField] int m_MaskInteraction = kVisibleInside;
|
||||||
[Tooltip("Use stencil for masking.")]
|
[Tooltip("Use stencil to mask.")]
|
||||||
[SerializeField] bool m_UseStencil = false;
|
[SerializeField] bool m_UseStencil = false;
|
||||||
|
[Tooltip("Use soft-masked raycast target.\n\nNote: This option is expensive.")]
|
||||||
|
[SerializeField] bool m_RaycastFilter = false;
|
||||||
|
|
||||||
|
|
||||||
//################################
|
//################################
|
||||||
|
@ -115,6 +117,10 @@ namespace Coffee.UIExtensions
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
else if (!m_RaycastFilter)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
var sm = _softMask;
|
var sm = _softMask;
|
||||||
for (int i = 0; i < 4; i++)
|
for (int i = 0; i < 4; i++)
|
||||||
|
@ -144,6 +150,15 @@ namespace Coffee.UIExtensions
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Use soft-masked raycast target. This option is expensive.
|
||||||
|
/// </summary>
|
||||||
|
public bool raycastFilter
|
||||||
|
{
|
||||||
|
get { return m_RaycastFilter; }
|
||||||
|
set { m_RaycastFilter = value; }
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The graphic associated with the soft mask.
|
/// The graphic associated with the soft mask.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
Loading…
Reference in New Issue