I'llI've made some buttons on my screen to navigate to other scenes of my Unity project, but the Click(string command) methodemethod doesn't trigger. I've placed a breakpoint on the bold line in code below, but the pointer never hithits that point.
public class GameNavigation : MonoBehaviour
{
public void Click(string command)
{
switch (command)
{
case "again":
Application.LoadLevel(Application.loadedLevel);
break;
case "go_to_menu":
Application.LoadLevel("Navigation");
break;
default:
break;
}
}
}
Here are also some screenshots form my Unity project.

What did I wrong?
Note one: I've made also this code that is called after the scene ends. the parameter command is always an empty string.
public void RestartLevel(string command)
{
switch (command)
{
case "again":
Application.LoadLevel(Application.loadedLevel);
break;
case "go_to_menu":
Application.LoadLevel("Navigation");
break;
default:
break;
}
}
If I place it in a comment, IveI get this error:
'Player' AnimationEvent 'RestartLevel' has no receiver! Are you missing a component?
Note two: I use also use a mouse down event for when the player must shoot.
Update: by a comment below I've made this code:
public Button btnAgain;
public Button btnMenu;
public void Start()
{
btnAgain.onClick.AddListener(() => {
Application.LoadLevel(Application.loadedLevel);
});
btnMenu.onClick.AddListener(() => {
Application.LoadLevel("Navigation");
});
}
The Start() methodemethod is always called, no problems whitwith it. But the Application.LoadLevel(...) code never executes when I click on the methodesmethods. However btnMenu and btnAgain aren't null.