Class XRController
The base type for all XR handed controllers.
Inherited Members
Namespace: UnityEngine.InputSystem.XR
Assembly: Unity.InputSystem.dll
Syntax
public class XRController : TrackedDevice
Properties
leftHand
A quick accessor for the currently active left handed device.
Declaration
public static XRController leftHand { get; }
Property Value
Type | Description |
---|---|
XRController |
Remarks
If there is no left hand connected, this will be null.
This also matches any currently tracked device that contains the 'LeftHand' device usage.
// To set up an Action to specifically target
// the left-hand XR controller:
var action = new InputAction(binding: "/<XRController>{leftHand}/position");
// To make the left-hand XR controller behave like the right-hand one
var controller = XRController.leftHand;
InputSystem.SetUsage(controller, CommonUsages.RightHand);
rightHand
A quick accessor for the currently active right handed device. This is also tracked via usages on the device.
Declaration
public static XRController rightHand { get; }
Property Value
Type | Description |
---|---|
XRController |
Remarks
If there is no left hand connected, this will be null. This also matches any currently tracked device that contains the 'RightHand' device usage.
Methods
FinishSetup()
Perform final initialization tasks after the control hierarchy has been put into place.
Declaration
protected override void FinishSetup()
Overrides
Remarks
This method can be overridden to perform control- or device-specific setup work. The most common use case is for looking up child controls and storing them in local getters.
public class MyDevice : InputDevice
{
public ButtonControl button { get; private set; }
public AxisControl axis { get; private set; }
protected override void OnFinishSetup()
{
// Cache controls in getters.
button = GetChildControl("button");
axis = GetChildControl("axis");
}
}</code></pre></example>