Class XRInteractionSimulator
A component which handles mouse and keyboard input from the user and uses it to simulate on-device interaction in XR Interaction Toolkit.
Inherited Members
Namespace: UnityEngine .XR.Interaction.Toolkit.Inputs.Simulation
Assembly: Unity.XR.Interaction.Toolkit.dll
Syntax
[AddComponentMenu("XR/Debug/XR Interaction Simulator", 11)]
[DefaultExecutionOrder(-29991)]
[HelpURL("https://docs.unity3d.com/Packages/com.unity.xr.interaction.toolkit@3.1/api/UnityEngine.XR.Interaction.Toolkit.Inputs.Simulation.XRInteractionSimulator.html")]
public class XRInteractionSimulator : MonoBehaviour
Remarks
This class does not directly manipulate the camera or controllers which are part of
the XR Origin, but rather drives them indirectly through simulated input devices.
Use the Package Manager window to install the XR Interaction Simulator sample into
your project to get sample mouse and keyboard bindings for Input System actions that
this component expects. The sample also includes a prefab of a Game
Note that the XR Origin must read the position and rotation of the HMD and controllers
by using Input System actions (such as by using Action
Properties
axis2DInput
The input used to control the value of one or more 2D Axis controls on the manipulated controller device(s).
Declaration
public XRInputValueReader<Vector2> axis2DInput { get; set; }
Property Value
Type | Description |
---|---|
XRInput |
Remarks
Typically bound to IJKL on a keyboard, and controls the primary and/or secondary 2D Axis controls on them.
axis2DTargets
One or more 2D Axis controls that keyboard input should apply to (or none).
Declaration
public Axis2DTargets axis2DTargets { get; set; }
Property Value
Type | Description |
---|---|
Axis2DTargets |
Remarks
Used to control a combination of the position (Position), primary 2D axis (Primary2DAxis), or secondary 2D axis (Secondary2DAxis) of manipulated device(s).
See Also
bodyTranslateMultiplier
Speed multiplier applied for body translation when triggered by input.
Declaration
public float bodyTranslateMultiplier { get; set; }
Property Value
Type | Description |
---|---|
float |
See Also
cameraTransform
The Transform that contains the Camera. This is usually the "Head" of XR Origins. Automatically set to main if unset.
Declaration
public Transform cameraTransform { get; set; }
Property Value
Type | Description |
---|---|
Transform |
controllerInputMode
The controller input mode which the controller should currently simulate.
Declaration
public ControllerInputMode controllerInputMode { get; }
Property Value
Type | Description |
---|---|
Controller |
currentHandExpression
The hand expression which the simulated hands should currently simulate.
Declaration
public SimulatedHandExpression currentHandExpression { get; }
Property Value
Type | Description |
---|---|
Simulated |
cycleDevicesInput
The input used to cycle between the different available devices.
Declaration
public XRInputButtonReader cycleDevicesInput { get; set; }
Property Value
Type | Description |
---|---|
XRInput |
cycleQuickActionInput
The input used to cycle the quick-action for controller inputs or hand expressions.
Declaration
public XRInputButtonReader cycleQuickActionInput { get; set; }
Property Value
Type | Description |
---|---|
XRInput |
See Also
deviceLifecycleManager
The corresponding manager for this simulator that handles the lifecycle of the simulated devices.
Declaration
public SimulatedDeviceLifecycleManager deviceLifecycleManager { get; set; }
Property Value
Type | Description |
---|---|
Simulated |
Remarks
If this value is not set, the simulator will either find a lifecycle manager in the scene or create one.
gripAmount
The amount of the simulated grip on the controller when the Grip control is pressed.
Declaration
public float gripAmount { get; set; }
Property Value
Type | Description |
---|---|
float |
See Also
gripInput
The input used to control the Grip control of the manipulated controller device(s).
Declaration
public XRInputButtonReader gripInput { get; set; }
Property Value
Type | Description |
---|---|
XRInput |
handExpressionManager
The corresponding manager for this simulator that handles the hand expressions.
Declaration
public SimulatedHandExpressionManager handExpressionManager { get; set; }
Property Value
Type | Description |
---|---|
Simulated |
Remarks
If this value is not set, the simulator will either find a hand expression manager in the scene or create one.
hmdIsTracked
Whether the HMD should report the pose as fully tracked or unavailable/inferred.
Declaration
public bool hmdIsTracked { get; set; }
Property Value
Type | Description |
---|---|
bool |
hmdTrackingState
Which tracking values the HMD should report as being valid or meaningful to use, which could mean either tracked or inferred.
Declaration
public InputTrackingState hmdTrackingState { get; set; }
Property Value
Type | Description |
---|---|
Input |
instance
The runtime instance of the XR Interaction Simulator.
Declaration
public static XRInteractionSimulator instance { get; }
Property Value
Type | Description |
---|---|
XRInteraction |
interactionSimulatorUI
The optional Interaction Simulator UI prefab to use along with the XR Interaction Simulator.
Declaration
public GameObject interactionSimulatorUI { get; set; }
Property Value
Type | Description |
---|---|
Game |
keyboardRotationDeltaInput
The keyboard input used to rotate by a scaled amount along or about the x- and y-axes.
Declaration
public XRInputValueReader<Vector2> keyboardRotationDeltaInput { get; set; }
Property Value
Type | Description |
---|---|
XRInput |
leftControllerIsTracked
Whether the left-hand controller should report the pose as fully tracked or unavailable/inferred.
Declaration
public bool leftControllerIsTracked { get; set; }
Property Value
Type | Description |
---|---|
bool |
leftControllerTrackingState
Which tracking values the left-hand controller should report as being valid or meaningful to use, which could mean either tracked or inferred.
Declaration
public InputTrackingState leftControllerTrackingState { get; set; }
Property Value
Type | Description |
---|---|
Input |
leftDeviceActionsInput
The input used for controlling the left-hand device's actions for buttons or hand expressions.
Declaration
public XRInputButtonReader leftDeviceActionsInput { get; set; }
Property Value
Type | Description |
---|---|
XRInput |
leftHandIsTracked
Whether the left hand should report the pose as fully tracked or unavailable/inferred.
Declaration
public bool leftHandIsTracked { get; set; }
Property Value
Type | Description |
---|---|
bool |
manipulatingFPS
Whether the simulator is manipulating the HMD, Left Controller, and Right Controller as if the whole player was turning their torso, similar to a typical FPS style.
Declaration
public bool manipulatingFPS { get; }
Property Value
Type | Description |
---|---|
bool |
manipulatingHMD
Whether the simulator is manipulating the HMD.
Declaration
public bool manipulatingHMD { get; }
Property Value
Type | Description |
---|---|
bool |
manipulatingLeftController
Whether the simulator is manipulating the Left Controller.
Declaration
public bool manipulatingLeftController { get; }
Property Value
Type | Description |
---|---|
bool |
manipulatingLeftDevice
Whether the simulator is manipulating the Left device (controller or hand).
Declaration
public bool manipulatingLeftDevice { get; }
Property Value
Type | Description |
---|---|
bool |
manipulatingLeftHand
Whether the simulator is manipulating the Left Hand.
Declaration
public bool manipulatingLeftHand { get; }
Property Value
Type | Description |
---|---|
bool |
manipulatingRightController
Whether the simulator is manipulating the Right Controller.
Declaration
public bool manipulatingRightController { get; }
Property Value
Type | Description |
---|---|
bool |
manipulatingRightDevice
Whether the simulator is manipulating the Right device (controller or hand).
Declaration
public bool manipulatingRightDevice { get; }
Property Value
Type | Description |
---|---|
bool |
manipulatingRightHand
Whether the simulator is manipulating the Right Hand.
Declaration
public bool manipulatingRightHand { get; }
Property Value
Type | Description |
---|---|
bool |
menuInput
The input used to control the Menu control of the manipulated controller device(s).
Declaration
public XRInputButtonReader menuInput { get; set; }
Property Value
Type | Description |
---|---|
XRInput |
mouseRotationDeltaInput
The mouse input used to rotate by a scaled amount along or about the x- and y-axes.
Declaration
public XRInputValueReader<Vector2> mouseRotationDeltaInput { get; set; }
Property Value
Type | Description |
---|---|
XRInput |
Remarks
Typically bound to the screen-space motion delta of the mouse in pixels.
See Also
mouseScrollInput
The input used to translate or rotate by a scaled amount along or about the z-axis.
Declaration
public XRInputValueReader<Vector2> mouseScrollInput { get; set; }
Property Value
Type | Description |
---|---|
XRInput |
Remarks
Typically bound to the horizontal and vertical scroll wheels, though only the vertical is used.
mouseScrollRotateSensitivity
Sensitivity of rotation along the z-axis (roll) when triggered by mouse scroll input.
Declaration
public float mouseScrollRotateSensitivity { get; set; }
Property Value
Type | Description |
---|---|
float |
See Also
primary2DAxisClickInput
The input used to control the Primary2DAxisClick control of the manipulated controller device(s).
Declaration
public XRInputButtonReader primary2DAxisClickInput { get; set; }
Property Value
Type | Description |
---|---|
XRInput |
primary2DAxisTouchInput
The input used to control the Primary2DAxisTouch control of the manipulated controller device(s).
Declaration
public XRInputButtonReader primary2DAxisTouchInput { get; set; }
Property Value
Type | Description |
---|---|
XRInput |
primaryButtonInput
The input used to control the PrimaryButton control of the manipulated controller device(s).
Declaration
public XRInputButtonReader primaryButtonInput { get; set; }
Property Value
Type | Description |
---|---|
XRInput |
primaryTouchInput
The input used to control the PrimaryTouch control of the manipulated controller device(s).
Declaration
public XRInputButtonReader primaryTouchInput { get; set; }
Property Value
Type | Description |
---|---|
XRInput |
quickActionControllerInputModes
The subset of quick-action controller buttons/inputs that a user can shift through in the simulator.
Declaration
public List<ControllerInputMode> quickActionControllerInputModes { get; set; }
Property Value
Type | Description |
---|---|
List<Controller |
See Also
resetInput
The input used to cause the manipulated device(s) to reset position or rotation
Declaration
public XRInputButtonReader resetInput { get; set; }
Property Value
Type | Description |
---|---|
XRInput |
Remarks
Resets position to zero and rotation to identity.
May be combined with axis constraints (x
rightControllerIsTracked
Whether the right-hand controller should report the pose as fully tracked or unavailable/inferred.
Declaration
public bool rightControllerIsTracked { get; set; }
Property Value
Type | Description |
---|---|
bool |
rightControllerTrackingState
Which tracking values the right-hand controller should report as being valid or meaningful to use, which could mean either tracked or inferred.
Declaration
public InputTrackingState rightControllerTrackingState { get; set; }
Property Value
Type | Description |
---|---|
Input |
rightHandIsTracked
Whether the right hand should report the pose as fully tracked or unavailable/inferred.
Declaration
public bool rightHandIsTracked { get; set; }
Property Value
Type | Description |
---|---|
bool |
rotateXSensitivity
Sensitivity of rotation along the x-axis (pitch) when triggered by input.
Declaration
public float rotateXSensitivity { get; set; }
Property Value
Type | Description |
---|---|
float |
See Also
rotateYInvert
A boolean value of whether to invert the y-axis of mouse input when rotating. A false value (default) means typical FPS style where moving up/down pitches up/down. A true value means flight control style where moving up/down pitches down/up.
Declaration
public bool rotateYInvert { get; set; }
Property Value
Type | Description |
---|---|
bool |
rotateYSensitivity
Sensitivity of rotation along the y-axis (yaw) when triggered by input.
Declaration
public float rotateYSensitivity { get; set; }
Property Value
Type | Description |
---|---|
float |
See Also
secondary2DAxisClickInput
The input used to control the Secondary2DAxisClick control of the manipulated controller device(s).
Declaration
public XRInputButtonReader secondary2DAxisClickInput { get; set; }
Property Value
Type | Description |
---|---|
XRInput |
secondary2DAxisTouchInput
The input used to control the Secondary2DAxisTouch control of the manipulated controller device(s).
Declaration
public XRInputButtonReader secondary2DAxisTouchInput { get; set; }
Property Value
Type | Description |
---|---|
XRInput |
secondaryButtonInput
The input used to control the SecondaryButton control of the manipulated controller device(s).
Declaration
public XRInputButtonReader secondaryButtonInput { get; set; }
Property Value
Type | Description |
---|---|
XRInput |
secondaryTouchInput
The input used to control the SecondaryTouch control of the manipulated controller device(s).
Declaration
public XRInputButtonReader secondaryTouchInput { get; set; }
Property Value
Type | Description |
---|---|
XRInput |
targetedDeviceInput
The currently active/targeted devices in the interaction simulator.
Declaration
public TargetedDevices targetedDeviceInput { get; set; }
Property Value
Type | Description |
---|---|
Targeted |
toggleManipulateHeadInput
The input used to toggle manipulation of only the head pose.
Declaration
public XRInputButtonReader toggleManipulateHeadInput { get; set; }
Property Value
Type | Description |
---|---|
XRInput |
toggleManipulateLeftInput
The input used to toggle enable manipulation of the left-hand controller when pressed.
Declaration
public XRInputButtonReader toggleManipulateLeftInput { get; set; }
Property Value
Type | Description |
---|---|
XRInput |
See Also
toggleManipulateRightInput
The input used to toggle enable manipulation of the right-hand controller when pressed.
Declaration
public XRInputButtonReader toggleManipulateRightInput { get; set; }
Property Value
Type | Description |
---|---|
XRInput |
See Also
toggleMouseInput
The input used to toggle associated inputs from a mouse device.
Declaration
public XRInputButtonReader toggleMouseInput { get; set; }
Property Value
Type | Description |
---|---|
XRInput |
See Also
togglePerformQuickActionInput
The input used to perform the currently active quick-action controller input or hand expression.
Declaration
public XRInputButtonReader togglePerformQuickActionInput { get; set; }
Property Value
Type | Description |
---|---|
XRInput |
See Also
togglePrimary2DAxisTargetInput
The input used to toggle enable manipulation of the Primary2DAxis of the controllers when pressed.
Declaration
public XRInputButtonReader togglePrimary2DAxisTargetInput { get; set; }
Property Value
Type | Description |
---|---|
XRInput |
See Also
toggleSecondary2DAxisTargetInput
The input used to toggle enable manipulation of the Secondary2DAxis of the controllers when pressed.
Declaration
public XRInputButtonReader toggleSecondary2DAxisTargetInput { get; set; }
Property Value
Type | Description |
---|---|
XRInput |
See Also
translateSpace
The coordinate space in which translation should operate.
Declaration
public Space translateSpace { get; set; }
Property Value
Type | Description |
---|---|
Space |
translateXInput
The input used to translate in the x-axis (left/right) while held.
Declaration
public XRInputValueReader<float> translateXInput { get; set; }
Property Value
Type | Description |
---|---|
XRInput |
translateXSpeed
Speed of translation in the x-axis (left/right) when triggered by input.
Declaration
public float translateXSpeed { get; set; }
Property Value
Type | Description |
---|---|
float |
See Also
translateYInput
The input used to translate in the y-axis (up/down) while held.
Declaration
public XRInputValueReader<float> translateYInput { get; set; }
Property Value
Type | Description |
---|---|
XRInput |
translateYSpeed
Speed of translation in the y-axis (up/down) when triggered by input.
Declaration
public float translateYSpeed { get; set; }
Property Value
Type | Description |
---|---|
float |
See Also
translateZInput
The input used to translate in the z-axis (forward/back) while held.
Declaration
public XRInputValueReader<float> translateZInput { get; set; }
Property Value
Type | Description |
---|---|
XRInput |
translateZSpeed
Speed of translation in the z-axis (forward/back) when triggered by input.
Declaration
public float translateZSpeed { get; set; }
Property Value
Type | Description |
---|---|
float |
See Also
triggerAmount
The amount of the simulated trigger pull on the controller when the Trigger control is pressed.
Declaration
public float triggerAmount { get; set; }
Property Value
Type | Description |
---|---|
float |
See Also
triggerInput
The input used to control the Trigger control of the manipulated controller device(s).
Declaration
public XRInputButtonReader triggerInput { get; set; }
Property Value
Type | Description |
---|---|
XRInput |
xConstraintInput
The input used to constrain the translation or rotation to the x-axis when moving the mouse or resetting. May be combined with another axis constraint to constrain to a plane.
Declaration
public XRInputButtonReader xConstraintInput { get; set; }
Property Value
Type | Description |
---|---|
XRInput |
See Also
yConstraintInput
The input used to constrain the translation or rotation to the y-axis when moving the mouse or resetting. May be combined with another axis constraint to constrain to a plane.
Declaration
public XRInputButtonReader yConstraintInput { get; set; }
Property Value
Type | Description |
---|---|
XRInput |
See Also
zConstraintInput
The input used to constrain the translation or rotation to the z-axis when moving the mouse or resetting. May be combined with another axis constraint to constrain to a plane.
Declaration
public XRInputButtonReader zConstraintInput { get; set; }
Property Value
Type | Description |
---|---|
XRInput |
See Also
Methods
Awake()
See Mono
Declaration
protected virtual void Awake()
GetResetScale()
Gets a Vector3 that can be multiplied component-wise with another Vector3 to reset components of the Vector3, based on axis constraint inputs.
Declaration
protected Vector3 GetResetScale()
Returns
See Also
OnDestroy()
See Mono
Declaration
protected virtual void OnDestroy()
OnDisable()
See Mono
Declaration
protected virtual void OnDisable()
OnEnable()
See Mono
Declaration
protected virtual void OnEnable()
ProcessAnalogButtonControlInput(ref XRSimulatedControllerState)
Update the state of manipulated controller device related to analog values only. This is used to adjust the grip and trigger values when the user adjusts the slider when not manipulating the device.
Declaration
protected virtual void ProcessAnalogButtonControlInput(ref XRSimulatedControllerState controllerState)
Parameters
Type | Name | Description |
---|---|---|
XRSimulated |
controllerState | The controller state that will be processed. |
ProcessAxis2DControlInput(ref XRSimulatedControllerState)
Process input from the user and update the state of manipulated controller device(s) related to 2D Axis input controls.
Declaration
protected virtual void ProcessAxis2DControlInput(ref XRSimulatedControllerState controllerState)
Parameters
Type | Name | Description |
---|---|---|
XRSimulated |
controllerState |
ProcessButtonControlInput(ref XRSimulatedControllerState)
Process input from the user and update the state of manipulated controller device(s) related to button input controls.
Declaration
protected virtual void ProcessButtonControlInput(ref XRSimulatedControllerState controllerState)
Parameters
Type | Name | Description |
---|---|---|
XRSimulated |
controllerState | The controller state that will be processed. |
ProcessControlInput()
Process input from the user and update the state of manipulated controller device(s) related to input controls.
Declaration
protected virtual void ProcessControlInput()
ProcessPoseInput()
Process input from the user and update the state of manipulated device(s) related to position and rotation.
Declaration
protected virtual void ProcessPoseInput()
ReadInputValues()
Reads any new values from the input readers and applies it to the corresponding value or state properties for further processing.
Declaration
protected virtual void ReadInputValues()
Update()
See Mono
Declaration
protected virtual void Update()