Shader “Custom/Px1” {
Properties {
_Col (“_ColorAmb”, Color) = (1,1,1,1)
}
SubShader {
Tags { “RenderType”=“Transparent” }
CGPROGRAM
#pragma surface surf BlinnPhong alpha
struct Input
{
float4 color : COLOR;
};
fixed4 _Col;
void surf (Input IN, inout SurfaceOutput o)
{
o.Albedo = _Col.rgb;
o.Alpha = _Col.a;
}
ENDCG
}
}
Tags { “RenderType”=“Transparent” }
CGPROGRAM
#pragma surface surf BlinnPhong alpha
should be
Tags { "RenderType"="Transparent" "Queue"="Geometry+1" }
CGPROGRAM
#pragma surface surf BlinnPhong alpha:auto
That will ensure the queue is correct (can add more if you want further in front) and also that you are alpha testing + blending
If your shader is correct, you can assign the color property like this:
material.SetColor("_Col", yourColor);
Where the material is your object material. You can assign it in inspector or get it like this:
var material = theObjectWithTheMaterialYouWantToChange.GetComponent<Renderer>().material;