I have a health gauge that has a sharp 45 degree angle. Basically I need someway to have an area on the screen under which other textures become invisible, but the alpha texture is still see-through.
I already tried rotating groups, etc. It works fine on normal GUI.matrix, but I have changed it so all of my other textures would scale nicely under every resolution.
How do I make the transparent hider texture? Or maybe there is some other approach?
This should work - assuming that your red “pointy-ended” object is drawn with a transparent shader (and therefore in the transparent queue), then create a new material using this shader and put it on the transparent object that you want to use to mask it.
Shader "Mask" {
SubShader {
Tags {
"Queue" = "Transparent-1" // Needs to be in a queue *before* the thing that you want to mask
"IgnoreProjector" = "True"
}
Pass {
Cull Back
Blend Zero One
Lighting Off
CGPROGRAM
#include "UnityCG.cginc"
#pragma vertex vert
#pragma fragment frag
v2f_img vert (appdata_base v)
{
v2f_img o;
o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
return o;
}
fixed4 frag (v2f_img IN) : COLOR
{
return fixed4(0,0,0,0);
}
ENDCG
}
}
}