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?
2 Answers
2
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;
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.
Edit>Project Settings>Script Execution Order
– whydoidoitOr by setting the GUI.depth
– whydoidoit