I’m using 2 simultaneous functions, one of which changes the colour of an object, and the second changes the Alpha of that same object. I’m already using Color.Lerp on the first one, so I can’t use it on the second one (otherwise, it will override the action of the 1st function)
My code is:
while (timer < time) {
timer += Time.deltaTime ;
theObjectColor = endColor;
float theObjectAlpha = theObject.renderer.material.color.a ;
theObjectAlpha = Mathf.Lerp(1,0, timer/time);
Debug.Log (theObjectAlpha);
yield return null;
}
The Debug.Log shows the right outcome but I can’t assign it to theObject’s alpha.
And when I try to assign it directly, I get the error “Cannot modify a value type return value of `UnityEngine.Material.color’”
How can I assign it to the renderer’s alpha?
Is there something similar to the “new Vector3()” technique, but for floats?
Thanks in advance