- Home /
GUI.DrawTexture over screen
Hi guys, i want to create fading effect before game'd started. My steps are:
initialize texture:
1) private Texture2D m_texture;
..................................
m_texture = new Texture2D(1, 1);
Apply Color to texture:
2) m_texture.SetPixel(0, 0, new Color(0, 0, 0, alpha));
m_texture.Apply();
Draw texture:
3) GUI.depth = 0;
GUI.DrawTexture(new Rect(0, 0, Screen.width, Screen.height), m_texture, ScaleMode.StretchToFill);
For all others components and windows i've setted GUI.depth greater than 0 (1...n)
But one gui window whatever draws over this texture...
Any idea ?
Answer by XienDev · Dec 22, 2012 at 10:23 AM
hm... i'm posting problematic windows and fading texture:
------------------------
Window OnGui
Fade OnGui
Fade OnGui
Window OnGui
------------------------
Window OnGui
Fade OnGui
Fade OnGui
Window OnGui
------------------------
thanx to all who looked here...
I found an answer:
1) be sure that u setting GUI.depth for any class presenting on a scene gameobjects does not have the same value
2) be sure tha gui.depth u need is always less then all others
3) gui depth are only works with different scripts (like script execution order at runtime and gui)
Answer by Catlard · Dec 22, 2012 at 10:13 AM
Is it possible the troublesome GUI draw call that you're talking about is happening AFTER your fade texture is being updated? What order are you drawing the GUI textures in?
Your answer
![](https://koobas.hobune.stream/wayback/20220613085809im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Gui appear and then fade to black 1 Answer
Repeat fade in and out 1 Answer
Making a GUI texture fade in and out depending on player proximity with enemy 2 Answers
How to make a GUITexture fade In? 1 Answer
rotating GUI texture by angle 2 Answers