This should be basic right? Put a texture in front of the camera and make the alpha lerp, move towards, whatever to 0. Well, this code:
Texture2D theTexture;
void OnGUI (){
GUI.color.a = Mathf.Lerp(0.0f, 1.0f, (Time.time / 2));
GUI.DrawTexture( new Rect(0,0,Screen.width, Screen.height), theTexture);
}
produces this error:
error CS1612: Cannot modify a value type return value of `UnityEngine.GUI.color'. Consider storing the value in a temporary variable
I understand this would work in javascript, but C# makes GUI.color read only, how would I go about this?
Thanks in advanced.
The problem is here: GUI.color.a = Mathf.Lerp(0.0f, 1.0f, (Time.time / 2));
You can not set GUI.color value seperately, you should set its value like this:
GUI.color = new Color(GUI.color.r, GUI.color.g, GUI.color.b, 0)
GUI.color = Mathf.Lerp(GUI.color, new Color(GUI.color.r, GUI.color.g, GUI.color.b, 1), (Time.time/2));