Hi,
I’m trying to create an 2D game in unity and I have some problems. I want to create the menu of the game, and I created the buttons as images to add scripts to each button to do something.
I’ve created this script to the button “Start Game”:
using System.Collections;
public class Jogo : MonoBehaviour
{
public string scene;
private bool loadLock=false;
void Update ()
{
if (Input.GetMouseButtonDown (0) && !loadLock)
{
LoadScene();
}
}
void LoadScene()
{
if (scene == null)
return;
loadLock = true;
Application.LoadLevel (scene);
}
}
And I add this script to the button, but this script is not only executed when I clicked the button but is executed anywhere I click. How I resolve this?