Published Unified Input Manager

Category: 

The Unified Input Manager (codename: CarbonInput) is now available on the Unity3D AssetStore. It serves as a replacement for the default Input Manager, giving you more control and better controller handling.

Unified Input Manager (CarbonInput)

CarbonInput is a simple extension for better gamepad management in Unity. Unity itself already provides a simple input facility for gamepads. It is based on defining the buttons and axes beforehand and uses them at runtime by their name.

float axis = Input.GetAxis("Horizontal");
bool fire = Input.GetButton("Fire1");

The input system works, but there are at least two problems with it:

  • String handling is error prone. It might happen that one accidentally writes "Fire 1" instead of "Fire1".
  • Gamepads are not standardized. The right thumbstick of a PS3 controller uses axis 3 and 5, while a XBox360 Controller uses axis 3 and 4.

CarbonInput defines a new Input System, which will try to recognize the used controller in order to use the correct mapping. You don't have to define any axis, CarbonInput is doing that for you and you can access the correct buttons directly:

// X axis of right thumbstick, automatically mapped to the correct Unity axis
float axis = GamePad.GetAxis(CAxis.RX);
// A-Button on XBox360 controller, Cross on PS3 controller
bool jump = GamePad.GetButton(CButton.A);

TouchInput

CarbonInput comes with an own touch input system. On systems like mobile devices, you often don't have a gamepad connected, therefor you have to use touch controls. You can use thumbsticks as well as normal buttons. Both are available in different styles, like a dark and a light style. Instead of using a generic button without a label, you could also use the predefined A, B, X and Y buttons. Of course you could also use your own images.

CarbonInput will handle any TouchInput the same way as any normal gamepad, so you don't have to change your code. Just drop a Thumbstick or Button prefab into your scene and you're done.

AssetStore

Get it now from the Unity3d AssetStore: Unified Input Manager
Leave a comment if you have any questions.