- Home /
How to access alpha value of transparent shader.
I have a Material which has an alpha texture and transparent shader. I want to controll its alpha value using script . How can I do that
Answer by anilgautam · Dec 13, 2012 at 10:59 AM
It works using public Color color = Color.red; renderer.material.color.a
Answer by BiG · Dec 06, 2012 at 10:55 AM
Using
renderer.material.color.a = 0.5;
,where 0.5 is, obviously, an example value.
It is showing Error Assets/Changer.cs(16,35): error CS1612: Cannot modify a value type return value of `UnityEngine.$$anonymous$$aterial.color'. Consider storing the value in a temporary variable
Answer by anilgautam · Dec 06, 2012 at 03:24 PM
public float Tlevel = 2; public Color color = Color.red; // Use this for initialization void Start () { } // Update is called once per frame void Update () { // color.a = Tlevel/10; color.a =Tlevel/10; renderer.material.color= color; renderer.material.color.a = Tlevel/10; }
Your answer
Follow this Question
Related Questions
alpha cutoff shader from map on map with already existing alpha channel 1 Answer
Trying to Add Basic Transparency to Shader 1 Answer
Custom shader converting to urp need help 1 Answer
Shader that draws alpha independent of transparency? 2 Answers
Shadergraph: How to amplify all of the white color of a texture? 1 Answer