I am trying to figure out how to map all UI "use" interaction to a key code instead of a mouse click. I found the post about triggering a button with a shortcut key when it's not focused (
http://www.tasharen.com/forum/index.php?topic=1148.0), but I want to change the "use" key for all UI elements in a panel, and still require focus.
My usage scenario is a fps where left mouse click is mapped to Fire1, and I want in-game UI elements that can be interacted with using rays from the UICamera on the Main Camera and triggered with a "use" key code.
I tried to modify the example above by simply changing [!UICamera.inputHasFocus] to [UICamera.inputHasFocus], and placed this script on a button and a checkbox, but it's not working.
Any input you can offer is appreciated.
void Update ()
{
if (UICamera.inputHasFocus)
{
if (Input.GetKeyDown(KeyCode.E))
{
SendMessage("OnPress", true, SendMessageOptions.DontRequireReceiver);
}
if (Input.GetKeyUp(KeyCode.E))
{
SendMessage("OnPress", false, SendMessageOptions.DontRequireReceiver);
SendMessage("OnClick", SendMessageOptions.DontRequireReceiver);
}
}
}