- Home /
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
Answer by J3-Gaming · Nov 09, 2011 at 08:42 PM
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.
http://unity3d.com/support/documentation/ScriptReference/GUI-color.html
Notice the GUI.color line is first, everything below it becomes yellow.
I'm gonna go with a face palm and a giant DUH! To myself. Thanks a majillion bagillion. Yes, that's a uint.
Glad to know it worked, we all need a second pair of eyes sometimes - that is what answers is for :)
Your answer
Follow this Question
Related Questions
GUI buttons glow/flash/fade between textures 0 Answers
Drawing 4 GUIButton's with a forloop. Need help changing color? 1 Answer
How to render a colored 2D rectangle. 6 Answers
fade in out multi images then go to next scene 1 Answer
Alpha set by tag in GUI.Label / GUI text behaves strange way 1 Answer