Fading an image drawn with GUI.DrawTexture

Hey, folks. I’ve got three lines of code in a larger script. I’m trying to figure out why I can’t modify the GUI texture alpha values. Is there something wrong with the way I’m calling them? It seems to work on some things but not on others…and not on fonts, either.

Here’s the code…this just causes it to pop in when the alpha is one…it’s changing the value of the alpha based on an iTweened transform. The image itself has alpha channel, as it’s a .png.

GUI.DrawTexture(lastNameRect,  lastNameTexture, ScaleMode.ScaleToFit, true, 0);	
GUI.DrawTexture(firstNameRect, firstNameTexture, ScaleMode.ScaleToFit, true, 0);
GUI.color.a = valueCube.transform.position.x;

Cheers

Simon

You might need to move the lines around:

GUI.color.a = valueCube.transform.position.x;
GUI.DrawTexture(lastNameRect,  lastNameTexture, ScaleMode.ScaleToFit, true, 0); 
GUI.DrawTexture(firstNameRect, firstNameTexture, ScaleMode.ScaleToFit, true, 0);

If I understand your code correctly, you want to modify the alpha of these drawn textures. So apply the alpha before you draw it.