Pages

Wednesday, March 16, 2016

Unity Player Key Bindings

As of Unity 5.3 there is no built in way to have the player re-assign or re-map keys. I was a bit surprised to learn that...

There are some solutions out there. Most of what I saw of the Asset Store was over kill for my uses. So I started to roll my own tool. Nothing fancy, but it allows the player to re-assign keys via UGUI interface.

I'm calling it "Click to Bind." It consists of two scripts. One that is placed per-key to be re-mapped and another is a manager script. The manager script contains 4 static functions that replace the standard Input.GetKey() or Input.GetKeyDown() etc... Brief documentation is included. There is also a demo scene.

Its a bit hard to "show" as you can't see my keyboard. Below is a quick GIF of the tool and very simple UI.



I may stick the script on the asset store. The scripts will be free, too lightweight to justify a price. All the source code will be included and should be easy to adapt for those with a modest knowledge of Unity and C#.

Download It 

For now the Unity Package can be found here (Box Storage). Feel free to use in anyway that's helpful. If you make some improvements or find some bugs please post in the comments below.

Script 1 - KeyBinding.CS


Script 2 - KeyBindingManager.CS



Saturday, March 5, 2016

Blender View Shortcuts in Unity

I was working to align gameObjects in Unity and was missing the view/rotate hotkeys from Blender. With a little bit of research and I was able to recreate most of the shortcuts.

The vertical rotations were more than I wanted to deal with... Unity does not seemly support number pad hotkeys so the shortcuts are with the standard numeric keys which means the shortcuts should also easily work with laptop keyboards.



Cut and paste the following code and place it into an Editor folder in Unity. Under "Tools" there should be "Blender Shortcuts" describing the hotkeys.