-
Notifications
You must be signed in to change notification settings - Fork 33
Home
XboxCtrlrInput
is a C# class for Unity3D that handles Xbox 360 controller input. It's used in the same way as Unity's Input
class. The goals of XboxCtrlrInput
are:
- To be able to make simple calls to Xbox controller input that works on Mac, Windows, and Linux (Ubuntu),
- And to be able to handle multiple Xbox controllers that works as you expect.
XboxCtrlrInput.cs
itself is not a Unity script and thus does not need to be attached to any GameObject. Unity's Input
class works in a similar way. Also like Input
, you cannot inherit from XboxCtrlrInput
because it's a sealed class. XboxCtrlrInput
should work on older versions of Unity that support joystick input.
Download the XboxCtrlrInput class file and then put it into your Unity project under the Assets/
folder. It can be anywhere in that folder.
Next, take the copy of the Unity Input Manager and replace the contents of your project's /ProjectSettings/InputManager.asset
with the contents of the copy.
It's not a MonoBehavior
, so no need to attach it like a script.
Note for Mac users: Be sure to install Tattie Bogle drivers.
- The code in
XboxCtrlrInput.cs
should work in Unity 4.x and above. - It might work in previous versions as long as they support joystick input.
- The example project requires Unity 4.2 or above (mostly due to the free text asset serialization).
- This class was mostly designed for desktop OS games in mind (Mac/Windows/Linux). This probably won't work for console or mobile development.
If you want to find out what currently works (such as button mappings), refer to the What Works page.
Please refer to the Issues page for the latest issues.
XboxButton |
Used to identify different Xbox buttons. |
---|---|
XboxDPad |
Used to refer to the four D-Pad directions. |
XboxAxis |
Used to identify all of the Xbox's analog inputs. |
There are none, as of yet anyway.
GetButton() |
Returns true if the specified button is held down. |
---|---|
GetButtonDown() |
Returns true at the frame the specified button starts to press down (not held down). |
GetButtonUp() |
Returns true at the frame the specified button is released. |
GetDPad() |
Returns true if the specified D-Pad direction is pressed down. |
GetAxis() |
Returns the analog number of the specified axis. |
GetAxisRaw() |
Returns the analog number of the specified axis without Unity's smoothing filter. |