What is the best way to use buttons?
I've created some buttons in my scene following a tutorial, but, I saw that in the script it use an 'OnMouseDown' method, but I need to add a collider to make it works. But, I the button have a click events to create that actions too, So, what is the correct way?, is common to use both ways ?
Answer by Firedan1176 · Aug 17, 2016 at 11:32 PM
The "general" or "correct" solution would be to use the input system's axes. They get direct control from the Input Manager, where users can customize buttons. That way, you don't have to specify "this mouse button" or "this key".
Defaultly, you can check for if the left mouse button was clicked with:
if(Input.GetAxisRaw("Fire1") == 1) { }
Your answer
Follow this Question
Related Questions
Button Click 1 Answer
Function OnClick problems(buttons) 0 Answers
Help with Randomized Sprite on GUI button click 0 Answers
Get keycode of pressed button 1 Answer
About button press sprint 1 Answer