Alpha Mask Helpers
GetAlphaMaskTexture
GetAlphaMaskTexturepublic Texture2D GetAlphaMaskTexture()
=> m_MeshRenderer && m_MeshRenderer.sharedMaterial
? m_MeshRenderer.sharedMaterial.mainTexture as Texture2D
: null;SampleAlphaAt
SampleAlphaAtpublic float SampleAlphaAt(Vector3 worldPos)
{
Texture2D tex = GetAlphaMaskTexture();
if (tex == null || !tex.isReadable) return -1f;
Vector2 uv = WorldToLocalUV(worldPos);
return tex.GetPixelBilinear(uv.x, uv.y).a;
}SetAlphaThreshold
SetAlphaThresholdLast updated