material color not changing
i have some problem. i am use this code
GetComponent<Renderer>().material.color = new Color(255,0,255,255);
Working but not what i want. look that.
Create new material but old one is still there. and gameobject using the old.
and then I used the following code
GetComponent<Renderer>().material.color.r = 50;
I got this error.
Assets/Script/Son.cs(32,53): error CS1612: Cannot modify a value type return value of `UnityEngine.Material.color'. Consider storing the value in a temporary variable
I do not know what to do.
Sorry for english :(.
resim.jpg
(77.3 kB)
Comment
Answer by The-Evster · Feb 13, 2017 at 08:04 PM
Try using this
GetComponent<Renderer>().material.color = new Color(50, GetComponent<Renderer>().material.color.g, GetComponent<Renderer>().material.color.b, GetComponent<Renderer>().material.color.a);
up vote if this helped