Hi All,
I’m new in unity3d , I have created a simple GUI with GUI texture and onGUI methods I have add multiple buttons
one of these button is to show about us image, I have tried to use
GUI.Box to show it , but It doesn’t work with me
Please any help will be appreciated
Thanks in advance
1 Answer
1
timsk
2
theres no built in function for modal gui’s or pop-ups, so you can code it yourself using something like this:
var aboutusbox : boolean = false;
var mainmenu : boolean = true;
function OnGUI()
{
if(mainmenu)
{
if (GUI.Button(rect(10,10,100,200),"about us"))
{
aboutusbox = true;
mainmenu = false;
}
}
if(aboutusbox)
{
GUI.Label (Rect (25, 25, 100, 30), "About us stuff here");
}
thats a very simple code, you would have to add your own groups, areas, skins or styles and everything else of course.
I am aware using switch…case statements is far better than this method, but I’m not sure the proper use for them.
A third way is using helper functions, for example
function OnGUI()
{
if (GUI.Button(rect(10,10,100,200),"about us"))
{
aboutusbox()
}
}
function aboutusbox()
GUI.Label(Rect (25, 25, 100, 30), "About us stuff here");
}