- Home /
Create a Start screen using guitexture over the main menu
Hey guys I am having some problems with my main menu. I am trying to implement a guitexture that covers the screen and is over the main menu which will fade and become inactive if I click on it. However, my guiTexture is covered up by my buttons and the texture2d I used to render the background. I have tried changing the depth of the gui texture but it doesn't work. Here is my OnGUI code if you need it:
GUI.DrawTexture(new Rect(0,0,originalWidth,originalHeight),Background);
//CreateNew,Load and Quit are different GUI Styles.
if(GUI.Button(new Rect(300,250,135,268),"",CreateNew) ){
Application.LoadLevel("New_Player");
}
//Load Player Button
if(GUI.Button(new Rect(850,250,135,268),"",Load))
Application.LoadLevel("Load_Player");
if(GUI.Button(new Rect(600,600,200,100),"Delete")){
PlayerPrefs.DeleteAll();
}
if(GUI.Button(new Rect(100,570,91,191),"",Quit)){
Application.Quit();
}
Is there a way such that i can choose the order in which the guiTexture is rendered? I would appreciate all the help I can get. Thanks a bunch!
Answer by fafase · Oct 29, 2013 at 10:52 AM
Because GUITexture are drawn before the OnGUI.
Anything OnGUI goes on top of the rest as being drawn last.
You have two solution though, either draw your covering texture inside the OnGUI with GUI.DrawTexture using the depth or Deactivate your OnGUI.
The first one is better as you get the texture covering the whole thing, the second one would remove the button and the start covering the screen.
How do I use GUI.DrawTexture using depth? When i try use my guitexture in the GUI.DrawTexture function, it returns an error.
What's the error? You can just use a Texture or Texture2D I'm pretty sure. A very good example of menu fading that you're trying to do is available in this Receiver games source code repository:
The error basically means that the GUI.DrawTexture cannot take the GUITexture in as a parameter. Anyways managed to understand what to do with what Josh did. Thanks a bunch.
Your answer
![](https://koobas.hobune.stream/wayback/20220613120837im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Reduce Draw call for Multiple GUI Textures with same Texture 1 Answer
Activate GuiTexture When Clicking on BoxCollider c# 1 Answer
WorldToScreenPoint returns the same value when facing the opposite direction. 0 Answers
How to prevent guitexture from vertically shrinking? 0 Answers
Drawing UI text on GUI.DrawTexture , How to do it ? 1 Answer