- Home /
assigning UI buttons to key
Im trying to add onscreen buttons for my game for mobile, is it possible to assign keys to UI buttons? I going back into my character script seems tedious. or any other suggestions? here is a screenshot
Answer by donutLaserDev · Mar 21, 2018 at 12:26 PM
You can make a script and in Update, check if Space (or any other key was pressed) and if it was, then call the method that the button itself calls. Now the method can be the actual method in some script or you can just assigned the method to the button's onClick and then invoke onClick event on the button like this: button.onClick.Invoke ()
.
Your answer
![](https://koobas.hobune.stream/wayback/20220613184926im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Can I Simulate the "Submit" Event with Gamepad Buttons? 0 Answers
Button.onClick.AddListener(() => Attack()); isn't running function math correctly 1 Answer
While mouse is pressed and moved to a button, button should be pressed as well 0 Answers