- Home /
when i click the GUI button it doesnt load the level
yes i did build the levels those are working but i don't know why this isnt working i have the log-in level-1 and this is level-2 so honesly i dont know why it isnt working?
this is javascript please make sure you LEAVE IN JAVASCRIPT
var details : boolean = false; var tunnelheight = 415; var tunnelwidth = 150; var tunnel1 = 115; var tunnel2 = 30;
function OnGUI ()
{
if (details)
{
GUI.Button(Rect(tunnelheight, tunnelwidth, tunnel1, tunnel2), "Enter");
if (GUI.Button(Rect(tunnelheight, tunnelwidth, tunnel1, tunnel2), "Enter")){
Application.LoadLevel (2);}
}
}
function OnTriggerEnter(other : Collider)
{
if(other.tag == "Player")
{
details = true;
}
}
function OnTriggerExit(other: Collider)
{
if(other.tag == "Player")
{
details = false;
}
}
Answer by cmpgk1024 · Aug 08, 2013 at 11:40 PM
You're making two buttons in the same place. The first one doesn't do anything. If I am interpreting your code right (you have given no information whatsoever about how it should work) the first button will not do anything whereas the second button will appear when a trigger enters the collider and allow you to proceed. Try removing the first button. If that doesn't work, check to make sure you are using the right level index number (check the build setting) or just use the scene name.
Thankyou it works now and it was because i had 2 buttons lol i didnt know that it worked like that thanks