Input.GetMouseButtonDown not working with UI elements
So I have a script for the menu you of my game, and when I click it doesn't matter if I click the button which has the script attached, it goes to the scene. Like I can click anywhere on the screen and it will do it.
void Update() { if(Input.GetMouseButtonDown(0)) { Application.LoadLevel("Strength") } }
Answer by Dave-Carlile · Nov 23, 2015 at 01:25 PM
If you take a look at the documentation for Input.GetMouseButtonDown you'll see that that function returns true if the mouse button is down. It doesn't care anything about where the mouse cursor is - it just cares about whether or not the button is down.
The UI system uses other means for capturing input. I would suggest using the Learn link at the top to go through the UI tutorials to learn how to use it.