16
NGUI 3 Support / How do I have a key press cause a button click?
« on: July 25, 2012, 04:52:12 PM »
I've got a toolbar of buttons that are clickable, and I'd like to have them also respond to shortcut keys. Currently I added a script onto each button that checks for their corresponding key press, and if so, calls SendMessage("OnClick"). This mostly works, in that the button's click sound goes off and any custom OnClick methods get called, but it doesn't call OnPress true and OnPress false the way it would with an actual mouse click, so the button doesn't animate. Is there a way to automatically simulate a full click on a button, or should I manually call OnPress(true) and OnClick and then start a CoRoutine to call OnPress(false) a second later?

