I am trying to get button to load new scene when clicked but when I click anywhere it happens
Here is my code:
#pragmastrict
functionUpdate () {
if(Input.GetMouseButton(0))
Application.LoadLevel(“TEST”);
}
Please help
I am trying to get button to load new scene when clicked but when I click anywhere it happens
Here is my code:
#pragmastrict
functionUpdate () {
if(Input.GetMouseButton(0))
Application.LoadLevel(“TEST”);
}
Please help
That normal, your condition is only when the mouse has been clicked, and not if the mouse has been clicked on the bouton…
Here is the code for make that, this code come from a tutorial, but it’s work:
void OnGUI()
{
const int buttonWidth = 84;
const int buttonHeight = 60;
if (
GUI.Button(
new Rect(
Screen.width / 2 - (buttonWidth / 2),
(2 * Screen.height / 3) - (buttonHeight / 2),
buttonWidth,
buttonHeight
),
"Start!"
)
)
{
Application.LoadLevel("TEST");
}
}
If possible I’d like the javascript code
Sorry, I have see that, but I don’t know how make that in Javascript, sorry. ![]()