Examples

All examples can be found in the Rewired/Examples folder. You should use these examples to learn how to work with the more advanced features of Rewired. More examples will be added in future updates.


Simple Control Remapping

(Included for Unity 5.0+)

NOTE: Rewired includes Control Mapper, a complete, configurable, responsive Unity UI-based control remapping system which can be used directly in your games. You can use it instead of writing your own remapping screen.

This is a very basic example of control remapping using the InputMapper class. This example only supports 1 Player, 1 Joystick, 1 Controller Map, and 1 mapping per Action, per controller type. No UI windows are used and conflict checking is handled automatically by InputMapper to keep this example small and focused.

 


Simple Combined Keyboard Mouse Remapping

(Included for Unity 5.0+)

NOTE: Rewired includes Control Mapper, a complete, configurable, responsive Unity UI-based control remapping system which can be used directly in your games. You can use it instead of writing your own remapping screen.

This is a very basic example of control remapping using the InputMapper class to combine keyboard and mouse bindings into a single column. This is not how Rewired is intended to work, but because some developers want to present it this way, this example has been provided.

This example only supports 1 Player, 1 mapping per Action, and only supports keyboard and mouse input. This example is exclusively meant to illustrate how to use multiple Input Mappers to poll for input on multiple input devices simultaneously. It also illustrates how to handle replacement assignments across controller types and Controller Maps.

No UI windows are used and conflict checking is handled automatically by InputMapper to keep this example small and focused.

 


Control Remapping 1

NOTE: Rewired includes Control Mapper, a complete, configurable, responsive Unity UI-based control remapping system which can be used directly in your games. You can use it instead of writing your own remapping screen.

This example demonstrates how to create a controller remapping screen using legacy Unity's GUI system. The demo shows examples of:

  • Assigning controllers to players
  • Mapping actions to controller, keyboard, and mouse elements
  • Conflict checking during element assignment
  • Using Map Categories and Action Categories to filter actions shown to user
  • Calibrating controller axes
  • Saving and loading controller maps, input behaviors, and calibration maps
  • Joystick identification for Unity input fallback platforms

The example is not meant to be a finished, drop-in controller remapping screen. (If you're looking for that, use Control Mapper.) Many games may not need such a complex setup, and you'll very likely want to replace Unity's legacy GUI with nGUI, Unity's new UI, or another GUI system. You can use this example to learn how to implement each aspect and customize it for your game's needs.

For a simpler example, see Simple Control Remapping.

 


Custom Controllers Touch

Note: Rewired now includes Touch Controls which can be used directly in your game. See Touch Controls for more information.

This example shows how to implement Custom Controllers, one possible use of which is on-screen touch controllers. The demo is not meant to be a drop-in touch controller. Use the sample code to learn how to work with Custom Controllers.

 


Custom Controllers Tilt

Note: Rewired now includes a Tilt Control which can be used directly in your game. See Component Controls - Tilt Control for more information.

This example shows how to handle basic tilt control on a mobile device using a Custom Controller.

 


Custom Platform

(Included for Unity 5.0+)

This example shows how to add support for platforms that are not natively supported by Rewired. This is an advanced topic and requires expert knowledge in C#.

See the documentation on this topic.

 


Eight Players

This example shows how to create basic joystick controls for 8 players and how to get input.

 


Fallback Joystick Identification

This example shows how you identify which joystick is which using Unity's input system as the input source on Windows. See Identifying joysticks on Windows fallback or Windows Webplayer platforms for more information.

 


Press Start To Join

This example shows one possible implementation of a "Press Start to Join" joystick assignment system. This is based on the example shown here under Method 1.

 


Press Any Button To Join

This example shows one possible implementation of a "Press Any Button to Join" joystick assignment system. This is based on the example shown here under Method 2.

 


Touch Controls 1Touch Controls 1

This example shows a working touch controller setup including a Touch Joystick, Touch Button, Touch Pad, Touch Region, and a Tilt Control. See Touch Controls for more information on touch controls and Component Controls - Tilt Control for more information on tilt control.

Example files are located in Rewired/Extras/TouchControls/Examples.

 


Touch Buttons 1Touch Buttons 1

This example shows various configuration options of Touch Buttons. See Touch Controls for more information on touch controls and Component Controls - Tilt Control for more information on tilt control.

Example files are located in Rewired/Extras/TouchControls/Examples.


Touch Joysticks 1

This example shows various Touch Joysticks. See Touch Controls for more information on touch controls.

Example files are located in Rewired/Extras/TouchControls/Examples.

 


Gamepad Template UIGamepad Template UI

(Included for Unity 5.0+)

This example shows how determine which Controller Template elements correspond to mapped Actions in a Player, both those that are currently active and those that are mapped. These concepts can be used to display a Controller Template based mapping UI, display Controller Template element names / glyphs instead of Controller-specific element names / glyphs, etc. The same concepts can be used to display help UI using Controller Template elements instead of Controller-specific elements.

This example is NOT meant to be modified and used in your game. It is only intended to teach the API.

 


Gamepad Template UIPlayer Mouse Sprite

(Included for Unity 5.0+)

This example shows how to use a Player Mouse through scripting to control as Sprite mouse pointer using any input device.


Gamepad Template UIPlayer Mouse Unity UI

(Included for Unity 5.0+)

This example shows how to use Player Mouse components and the Rewired Standalone Input Module to control 4 mouse pointers using any input device to interact with Unity UI.


Gamepad Template UIDualShock 4 Special Features

This example shows how to access the special features on the Dual Shock 4.