Over-ridding the space bar for OVRMenu
Several alpha testers have suggested that I change the function of the space key in the forthcoming Oculus Share app "Hitchhiker". The current function of the space key is to bring up the OVRMenu. The new function would be to jump off the spaceship. However, it appears the current OVR code hardwires the space key to bring up the OVRMenu. It is common in game design for the space key to cause the player to 'jump' in one fashion or another so I suspect others will end up in my situation and I'd like to post a solution which may improve the maintainability of app developer's code over the long run.
In the forums I've found this thread:
viewtopic.php?f=37&t=6315&p=87412&hilit=menu#p87412
I prefer not to make any changes to the OVR code, a practice which allows me to upgrade to the current release quickly and easily. I'm hoping that by sharing the changes I've made, someone can show me how to do it in a more maintainable fashion or that the technique gets adopted by the OVR unityIntegration package.
Here's the approach:
1) Free the space bar from the OVR code by tying the script's invocation to a button variable labeled "Menu". (Reference: http://unity3d.com/learn/tutorials/modules/beginner/scripting/get-button-and-get-key)
2) Add a "Menu" input control to Unity3d.
Details:
1) Change code in OVRMainMenu.cs
a) Change line 846
FROM: bool SpaceHit = Input.GetKey("space");
TO: bool SpaceHit = Input.GetButton("Menu" );
2) Add a "Menu" input control to Unity:
a) In Unity go to edit> project settings> input
b) Increment the 'Size' field by one
c) Change the name of the newly created field to "Menu"
d) Change the positive input field to 'm', or whatever key you'd like to use to invoke the MainMenu.
Please take this as a constructive suggestion to address the growing number of key bindings in 0.3.2 beta. I may be totally wrong in my approach so please feel free to suggest other ways to "free the space bar" or over-ride the OVR default key bindings.
In the forums I've found this thread:
viewtopic.php?f=37&t=6315&p=87412&hilit=menu#p87412
I prefer not to make any changes to the OVR code, a practice which allows me to upgrade to the current release quickly and easily. I'm hoping that by sharing the changes I've made, someone can show me how to do it in a more maintainable fashion or that the technique gets adopted by the OVR unityIntegration package.
Here's the approach:
1) Free the space bar from the OVR code by tying the script's invocation to a button variable labeled "Menu". (Reference: http://unity3d.com/learn/tutorials/modules/beginner/scripting/get-button-and-get-key)
2) Add a "Menu" input control to Unity3d.
Details:
1) Change code in OVRMainMenu.cs
a) Change line 846
FROM: bool SpaceHit = Input.GetKey("space");
TO: bool SpaceHit = Input.GetButton("Menu" );
2) Add a "Menu" input control to Unity:
a) In Unity go to edit> project settings> input
b) Increment the 'Size' field by one
c) Change the name of the newly created field to "Menu"
d) Change the positive input field to 'm', or whatever key you'd like to use to invoke the MainMenu.
Please take this as a constructive suggestion to address the growing number of key bindings in 0.3.2 beta. I may be totally wrong in my approach so please feel free to suggest other ways to "free the space bar" or over-ride the OVR default key bindings.
