- Home /
Fading a GUI.DrawTexture?
I am trying to use a white texture that I draw full screen as a transition effect between different menus that I am using. The issue arises because I am using many GUI elements, and I need this white texture to be on top of everything else when it fades. I have tried a few different methods, but since I can't control a textures alpha directly when it is drawn as a GUI element, I can't seem to figure out a solution.
Any ideas?
Answer by simonmc · Apr 11, 2013 at 05:58 AM
you can change the alpha component by setting GUI.color before drawing the texture.
e.g
Color c = GUI.color;
Color old = c;
c.a = fadeAlpha;
GUI.color = c;
GUI.DrawTexture(....);
GUI.color = old;
Answer by whydoidoit · Apr 11, 2013 at 06:00 AM
You can control the alpha of the texture by setting GUI.color:
void OnGUI()
{
var c = Color.white;
c.a = 0.4f;
GUI.color = c;
GUI.DrawTexture(new Rect(20,20,400,300), texture);
}
You can control the order by setting the script execution order of your OnGUI script for the top level.
Your answer
Follow this Question
Related Questions
Movie GUI Texture Alpha? 1 Answer
Alpha cutoff for a GUI Texture? 2 Answers
Dynamic Alpha Gradient Texture Collision Detection 0 Answers
Edges on Transparent GUI - Still not working 1 Answer
Help with destroying guiRect? 0 Answers