I have a texture applied to a plane, and wish to dynamically set the alpha. The problem is fading the texture using the alpha channel of material.color, after manually assigning the colour white at start.
I have this script which works when using the default transparent diffuse, but not any of the unlt shaders. The shaders for unlit from owlchemy labs didnt work either, even though I can see the alpha bar moving up and down.
// START
theMaterial = gameObject.renderer.material;
theMaterial.color = Color.white;
// UPDATE
theMaterial.color = Color( theMaterial.color.r, theMaterial.color.g, theMaterial.color.b, health * 0.01 );
How do I change the alpha of a texture using an unlit shader? Which shader should I use? Does anyone have a link to a shader (shaderlab and UnityGems are my first call when have time to learn CG and shaders). Thanks =]
Owlchemy Labs Unlit Alpha Shader :
//Originally by Bill Vinton (Sync1B)
Shader "Unlit/AlphaSelfIllum" {
Properties {
_Color ("Color Tint", Color) = (1,1,1,1)
_MainTex ("SelfIllum Color (RGB) Alpha (A)", 2D) = "white"
}
Category {
Lighting On
ZWrite Off
Cull Back
Offset -1, -1
Blend SrcAlpha OneMinusSrcAlpha
Tags { "Queue" = "transparent" }
SubShader {
Material {
Emission [_Color]
}
Pass {
SetTexture [_MainTex] {
Combine Texture * Primary, Texture * Primary
}
}
}
}
}