- Home /
Question by
GamerBot · Feb 27, 2013 at 07:19 PM ·
menuloadlevelinstructions
How can I clear the menu buttons when clicking a button that loads another screen?
I having problems with the menu loadlevel and Instructions loadlevel. Whenever I'm on the menu screen and press the Instructions button it sends to the that screen, but I still see the buttons from the menu screen.
edit(copied and reformatted from comment)
#pragma strict
var beep : AudioClip;
var menuSkin : GUISkin;
var areaHeight : float;
var areaWidth : float;
function OnGUI()
{
GUI.skin = menuSkin;
var ScreenX = ((Screen.width * 0.5) - (areaWidth * 0.5));
var ScreenY = ((Screen.height * 0.5) - (areaHeight * 0.5));
GUILayout.BeginArea (Rect(ScreenX,ScreenY,areaWidth,areaHeight));
if(GUILayout.Button("Play"))
{
OpenLevel ("Island Level");
}
if(GUILayout.Button("Instructions"))
{
OpenLevel ("Instructions");
}
if(GUILayout.Button("Quit"))
{
Application.Quit();
}
GUILayout.EndArea();
}
function OpenLevel(level : String)
{
audio.PlayOneShot(beep);
yield new WaitForSeconds(0.35);
Application.LoadLevel(level);
}
@script RequireComponent(AudioSource)
Comment
If you are using GUI.Buttons, then they will appear as long as you are displaying them in OnGUI(). Post your scripts and someone on the list can likely spot the problem.
On the answers/comment,click the code sample, the binary sign, then copy/past
you has to make an if statement to show the correct GUI menus depending the loaded scene
void OnGUI() {
if(Application.loadedLevelName == "$$anonymous$$enuScreen"){
//Your gui.buttons, etc, for the menuscreen scene here
}
if(Application.loadedLevelName == "Instructions"){
//Your gui.buttons, etc, for the Instructions screen scene here
}
}
Your answer
Follow this Question
Related Questions
split-screen 'ready up' game start screen 0 Answers
Photon stays in "connecting" status 0 Answers
Using start function after loading level a second time 0 Answers
Loading scene from WP8 menu 1 Answer
Reloading Level problem 0 Answers