Hi all,
Just wanted to let you know that I have managed to get Rewired working with NGUI.
Using Unity 5.4, NGUI 3.10.0 and Rewired 1.0.0.97
Below you find the code I'm using. I removed some stuff, since I'm primarily using it for menu navigation.
* You need to set up the actions for the system player in the Rewired Input Manager.
* You need to set up a joystick map, to create elements (buttons) and map them to the actions.
* You need to set up a keyboard map in a similar way.
* You need to make sure the system player has these maps assigned and enabled.
* The system player of course needs to have a active controller assigned, otherwise it won't work!
* I created a UIControl behavior with high Digital Sensitivity and Gravity (10000), which I'm using for the actions.
* You need to have this script running on a gameobject.
* You DO need to have Horizontal and Vertical axes defined in the Unity input manager, and have them set in UICamera script on the UI Camera.
* Some other weird stuff I forgot

.
Diederik / Xform
using UnityEngine;
using System.Collections;
public class RewiredNGUI : MonoBehaviour
{
// Rewired Button Actions
private static string _actionBottomRow1 = "UISubmit";
private static string _actionBottomRow2 = "UICancel";
// Rewired Axis Actions
private static string _leftStickX = "Horizontal";
private static string _leftStickY = "Vertical";
private static string _dPadX = "UIHorizontal";
private static string _dPadY = "UIVertical";
void Start ()
{
UICamera.GetKey = GetKey;
UICamera.GetKeyDown = GetKeyDown;
UICamera.GetKeyUp = GetKeyUp;
UICamera.GetAxis = GetAxis;
}
static bool GetKeyDown (KeyCode key)
{
if (key >= KeyCode.JoystickButton0)
{
Rewired.Player rewiredSystemPlayer = Rewired.ReInput.players.GetSystemPlayer(); // Done every time this is called???
switch (key)
{
case KeyCode.JoystickButton0: return rewiredSystemPlayer.GetButtonDown(_actionBottomRow1); // Action bottom row 1 (Xbox "A" button, for instance)
case KeyCode.JoystickButton1: return rewiredSystemPlayer.GetButtonDown(_actionBottomRow2); // Action bottom row 2 (Xbox "B" button, for instance)
}
}
return false;
}
static bool GetKey (KeyCode key)
{
if (key >= KeyCode.JoystickButton0)
{
Rewired.Player rewiredSystemPlayer = Rewired.ReInput.players.GetSystemPlayer(); // Done every time this is called???
switch (key)
{
case KeyCode.JoystickButton0: return rewiredSystemPlayer.GetButton(_actionBottomRow1); // Action bottom row 1 (Xbox "A" button, for instance)
case KeyCode.JoystickButton1: return rewiredSystemPlayer.GetButton(_actionBottomRow2); // Action bottom row 2 (Xbox "B" button, for instance)
}
}
return false;
}
static bool GetKeyUp (KeyCode key)
{
if (key >= KeyCode.JoystickButton0)
{
Rewired.Player rewiredSystemPlayer = Rewired.ReInput.players.GetSystemPlayer(); // Done every time this is called???
switch (key)
{
case KeyCode.JoystickButton0: return rewiredSystemPlayer.GetButtonUp(_actionBottomRow1); // Action bottom row 1 (Xbox "A" button, for instance)
case KeyCode.JoystickButton1: return rewiredSystemPlayer.GetButtonUp(_actionBottomRow2); // Action bottom row 2 (Xbox "B" button, for instance)
}
}
return false;
}
static float GetAxis (string name)
{
Rewired.Player rewiredSystemPlayer = Rewired.ReInput.players.GetSystemPlayer(); // Done every time this is called???
switch (name)
{
case "Horizontal": return rewiredSystemPlayer.GetAxis(_leftStickX) + rewiredSystemPlayer.GetAxis(_dPadX);
case "Vertical": return rewiredSystemPlayer.GetAxis(_leftStickY) + rewiredSystemPlayer.GetAxis(_dPadY);
}
return 0;
}
}