Newest update -
CustomInput is now available for purchase on the Asset Store.
I can be reached at CustomInputSupport @ hotmail.com (or this thread!) if you have any comments or questions and I’ll get back to you as soon as I can. (This information is being added to the store page as well)
Video demo of the developer side of things - setting up CI is easy as pie.
Full(ish) documentation included with CI
Webplayer Demo
Screenshots:
Inspector preview
Inspector Cheat Sheet
In-game editor preview (customizable)
Are your players irate that they have to restart your game to change the controls?
Angry that they can’t switch to their favorite joystick? Maybe the button assignments are wrong - every joystick has a different layout; it’s impossible to catch them all.
Well, not quite impossible.
Enter CustomInput - set up your controls in the Inspector using a slick, simple interface. Give your users the standard controls for your first-person shooter - WASD movement, mouselook, that sort of thing.
When an AZERTY keyboard user comes along, point them to the pause menu - where you’ve implemented CustomInput’s default key editor. Let them change it over to ZQSD with just a few clicks and you will have one happy camper on your hands.
“Surely it doesn’t just… work?”
Watch this:
function OnGUI() {
if ( paused inControlEditMode ) {
CustomInput.InGameControlEdit();
}
}
Yes, that’s really all CustomInput needs to operate (of course, you have to define and set ‘paused’ and ‘inControlEditMode’).
That’ll fill your screen with the control editor, but you don’t want the -whole screen- filled up, so go back to the Inspector and fiddle with the editor’s widths until you can do this:
function OnGUI() {
GUILayout.BeginHorizontal();
GUILayout.BeginVertical();
GUILayout.Button("A button");
GUILayout.Button("Another");
GUILayout.EndVertical();
GUILayout.BeginVertical();
CustomInput.InGameControlEdit();
GUILayout.Button("More button");
GUILayout.EndVertical();
GUILayout.EndHorizontal();
}
Fit the editor in any space you want with several settings to shrink its size, and pixel-perfect control over its default settings.
“Well, okay, but getting all the controls set up must be a pain.”
Just tell CustomInput what axes you’re using in Unity’s InputManager (still no way to read those, unfortunately). Open a control group, click the ‘New Control’ button, and select an axis and/or some keys to activate it. You can even set up tooltips for your players.
Take a gander at CustomInput’s Inspector:
CustomInput Inspector Cheat Sheet
It looks daunting, but once you get the hang of it it only takes a few seconds per control!
“LeftShift? Ew, that’s a terrible key name! My players will hate me. Sad face.”
Not at all! You can change the display name of any number of keys, and CustomInput automagically changes the names of the most egregious offenses - Mouse0 becomes Left Click, Alpha0 and Keypad0 both become 0, Joystick2Button14 becomes… well, Joystick 2 - Button 14. A little better, at least.
“So how do I use this in my code? It’s gonna take hours to convert from Input calls, isn’t it?”
Hopefully not. Let’s try one:
if ( Input.GetAxis("Horizontal") < 0 )
// becomes:
if ( CustomInput.Control("Player1","MoveH").GetAxis() < 0 )
// and:
if ( Input.GetKey(KeyCode.X) )
// becomes:
if ( CustomInput.Control("Player1","Examine").AnyKey() )
You can even cache your controls to tighten that up a bit:
if ( myControl[ ControlEnum.P1MoveH ].GetAxis() < 0 )
“I dunno; what if the user assigns the Z key to everything?”
CustomInput knows when your users are being indecisive. You have fine control over which controls are allowed to share keys - for example, you might not worry about your “Player 1” controls conflicting with your “Menu” controls. Just ask CustomInput if its controls are okay with a single function call, and don’t let your player escape the menus until they are!
Don’t forget to check out the Webplayer Demo
Press ‘escape’ in the webplayer to get to the pause screen, then click on Controls to see what CustomInput looks like with my basic GUISkin applied. Change the controls around, and try to break it! The demo does support whichever two-stick joystick Unity has decided is “joystick 1” (if you only have one, and it works with Unity, it’ll work with the demo).
Comes with all source code - currently in Javascript with plans to port to C#.
===== =====
Built this because, honestly, every single game should allow me to change my controls without restarting. And if there’s an easy way to make controls customizable, well, there’ll be more games where I can do that! Win-win.
Anyone have any concerns or suggestions about this? Is there some functionality I might be missing? Is “CustomInput” a stupid name and you’ll hate typing it?
One thing of note - I have not discovered how to tell if the user is pressing left or right Shift. RIght now the program just assumes left shift is the one you meant; and if you click the button again and press left shift again, it switches to right shift. That won’t be the behaviour in the final product; I’ll find some way to differentiate.