- Home /
gui draw rexture problem
if(GUI.Button(Rect(3,810,80,35),GUIContent (" START", "start")))
{
GUI.DrawTexture(Rect(0,0,500,500),start1);
}
if(GUI.Button(Rect(85,810,80,35),GUIContent (" CONTINUE", "continue")))
{
GUI.DrawTexture(Rect(0,0,500,500),continue1);
}
when i am pressing start button the draw texture is not drawing the texture start1.When i am putting it outside if condition it is working fine.Is there any problem when we put a gui inside another gui
Answer by poncho · Mar 10, 2011 at 03:26 PM
this code will just draw the texture for the frame that the button was pressed instead of that you need to add a boolean that turns on when you hit start
bool myboolStart =false;
bool myboolContinue = false;
void OnGUI()
{
if(GUI.Button(Rect(3,810,80,35),GUIContent (" START", "start")))
{
myboolStart = true;
}
if(myboolStart)
GUI.DrawTexture(Rect(0,0,500,500),start1);
if(GUI.Button(Rect(85,810,80,35),GUIContent (" CONTINUE", "continue")))
{
myboolContinue = true;
}
if(myboolContinue)
GUI.DrawTexture(Rect(0,0,500,500),continue1);
}
this will do the trick -edit- im using C# just try to use this on js dont just copy paste it
what is the reason why cannot we able to put gui inside a gui
uh?, yes, of course you can have a gui inside a gui, but it will be shown just the frame it was pressed, so its no use for that try pressing the button lots of time to see what i mean also there are the GUI Boxes or something like that havent used that in a while but is a group of guis inside the gui of the box
Your answer
Follow this Question
Related Questions
Replacing Gui.DrawTexture or gui textures in C#? 0 Answers
Help with destroying guiRect? 0 Answers
Can you use GUI.DrawTexture to make a clickable button 3 Answers
GUI text appears behind drawn texture. 0 Answers
Getting Error "DrawGUITexture: Texture is Null" when using Graphics.DrawTexture in OnGUI() 2 Answers