Hi,
How can I detect if any of hardware buttons is getting pressed and which one is it on Android?
Thanks.
Hi,
How can I detect if any of hardware buttons is getting pressed and which one is it on Android?
Thanks.
They are dispatched as regular key events. The following script handles the standard menu and back buttons:
function OnGUI() {
var e = Event.current;
switch (e.type) {
//case EventType.KeyDown:
case EventType.KeyUp:
switch (e.keyCode) {
case KeyCode.Menu:
OnMenuButton();
e.Use();
break;
case KeyCode.Escape:
OnBackButton();
e.Use();
break;
}
break;
}
}