- Home /
cannot access the next scene
firstly, the scene will be loaded to the TPS4 scene after the user click on the text from mainmenu scene...after the user done with the game, a new scene(win scene) will appear which is ask the user if the user want to play again or exit to desktop...when the user hit play again, the mainmenu scene is loaded...I tried to access mainmenu scene after the user chose play again. when the mainmenu scene appear, the user will click on the text which is loaded to the mainmenu scene again..however, it doesn't loaded..just stuck in the mainmenu scene
anyone can fix it??
this is my code for mainmenu scene
var soundhover : AudioClip;
var beep : AudioClip;
var QuitButton : boolean = false;
function OnMouseEnter(){
audio.PlayOneShot(soundhover);
}
function OnMouseUp(){
audio.PlayOneShot(beep);
yield new WaitForSeconds(0.35);
if(QuitButton){
Application.Quit();
}
else{
Application.LoadLevel("TPS4");
}
}
and this is my code for win scene
var buttonHeight:float=500;
var buttonWidth:float=500;
var buttonSpace:float=50;
var titleTexture:Texture2D;
var customSkin:GUISkin;
var customStyle:GUIStyle;
function OnGUI(){
GUI.skin = customSkin;
GUILayout.BeginArea(Rect(Screen.width/2-buttonWidth/2,Screen.height/2-buttonHeight/2,buttonHeig
ht,buttonWidth),customStyle);
GUILayout.Space(50);
GUILayout.Label(titleTexture);
GUILayout.Space(buttonSpace);
//GUILayout.Box("Please Select");
if(GUILayout.Button("Play Again")){
Application.LoadLevel("mainmenu");
}
GUILayout.Space(buttonSpace);
if(GUILayout.Button("Exit to Desktop")){
Application.Quit();
}
GUILayout.Space(buttonSpace);
GUILayout.EndArea();
}
Answer by Fred_Vicentin · May 07, 2013 at 06:26 PM
Did you added the scene on the Build ? Opening the scene and going to file>build> button "Add Current" ?
You can also try to access the scene using Application.LoadLevel(1); (Or the number that appear on the TPS4 scene)
yes...I have built it...I got the error when I try to re-access it for the second time...The scene could be access by another scene before...
Oh, sorry, now I understood, try Application.LoadLevel(Application.loadedLevel);
Or Application.LoadLevel(Application.loadedLevelName == "Name")