private void AddDeviceRow(Controller controller) { Rewired.Joystick joystick = controller as Rewired.Joystick; InputDeviceRow inputDeviceRow = UnityEngine.Object.Instantiate <InputDeviceRow>(this._row); inputDeviceRow.transform.parent = this._table.transform; inputDeviceRow.transform.localPosition = Vector3.zero; inputDeviceRow.transform.localScale = Vector3.one; inputDeviceRow._label.text = ((joystick == null) ? controller.name : joystick.name); if (!this._allDevicesCheckbox.value && controller.type == ControllerType.Joystick) { inputDeviceRow._checkbox.value = InputDeviceManager.UseDevice(controller.hardwareIdentifier); EventDelegate eventDelegate = new EventDelegate(); eventDelegate.target = this; eventDelegate.methodName = "ToggleDevice"; eventDelegate.parameters[0] = new EventDelegate.Parameter(inputDeviceRow._checkbox); eventDelegate.parameters[1] = new EventDelegate.Parameter(controller.id); eventDelegate.parameters[2] = new EventDelegate.Parameter(controller.hardwareIdentifier); inputDeviceRow._checkbox.onChange.Add(eventDelegate); } else { UnityEngine.Object.Destroy(inputDeviceRow._checkbox.gameObject); } }
public void ToggleDevice(UIToggle checkbox, int id, string hardwareId) { if (checkbox.value != InputDeviceManager.UseDevice(hardwareId)) { PlayerPrefs.SetInt("device_" + hardwareId, (!checkbox.value) ? 0 : 1); PlayerPrefs.Save(); InputMapping.InitControllers(); } }