Input Simulation Service
The Input Simulation Service emulates the behaviour of devices and platforms that may not be available in the Unity editor. Examples include:
- HoloLens or VR device head tracking
- HoloLens hand gestures
- HoloLens 2 articulated hand tracking
- HoloLens 2 eye tracking
Users can use a conventional keyboard and mouse combination to control simulated devices at runtime. This allows testing of interactions in the Unity editor without first deploying to a device.
This does not work when using Unity's XR Holographic Emulation > Emulation Mode = "Simulate in Editor". Unity's in-editor simulation will take control away from MRTK's input simulation. In order to use the MRTK input simulation service, you will need to set XR Holographic Emulation to Emulation Mode = "None"
Enabling the Input Simulation Service
Input simulation is enabled by default in MRTK.
- Type must be Microsoft.MixedReality.Toolkit.Input > InputSimulationService.
- Platform(s) by default includes all Editor platforms, since the service uses keyboard and mouse input.
Input simulation tools window
Enable the input simulation tools window from the Mixed Reality Toolkit > Utilities > Input Simulation menu. This window provides access to the state of input simulation during play mode.
A prefab for in-editor buttons to control basic hand placement can be specified in the input simulation profile under Indicators Prefab. This is an optional utility, the same features can be accessed in the input simulation tools window.
The viewport indicators are disabled by default, as they currently sometimes interfere with Unity UI interactions, see issue #6106. To enable, add the InputSimulationIndicators prefab to Indicators Prefab.
Hand icons show the state of the simulated hands:
- The hand is not tracking. Click to enable the hand.
- The hand is tracked, but not controlled by user. Click to hide the hand.
- The hand is tracked and controlled by user. Click to hide the hand.
- Click to reset the hand to default position.
Head movement can be emulated by the Input Simulation Service.
To rotate the camera:
- Hover over the viewport editor window. You may need to click the window to give it input focus if button presses don't work.
- Press and hold the Mouse Look Button (default: Right mouse button).
- Move the mouse in the viewport window to rotate the camera.
- Use the scroll wheel to roll the camera around the view direction.
Camera rotation speed can be configured by changing the Mouse Look Speed setting in the input simulation profile.
Alternatively use the Look Horizontal/Look Vertical axes to rotate the camera (default: game controller right thumbstick).
To move the camera:
Use the Move Horizontal/Move Vertical axes to move the camera (default: WASD keys or game controller left thumbstick).
Camera position and rotation angles can be set explicitly in the tools window as well. The camera can be reset to its default using the Reset button.
The input simulation supports emulated hand devices. These virtual hands can interact with any object that supports regular hand devices, such as buttons or grabbable objects.
Hand Simulation Mode
In the input simulation tools window the Hand Simulation Mode setting switches between two distinct input models. The default mode can also be set in the input simulation profile.
Articulated Hands: Simulates a fully articulated hand device with joint position data.
Emulates HoloLens 2 interaction model.
Interactions that are based on precise positioning of the hand or use touching can be simulated in this mode.
Gestures: Simulates a simplified hand model with air tap and basic gestures.
Emulates HoloLens interaction model.
Focus is controlled using the Gaze pointer. The Air Tap gesture is used to interact with buttons.
Controlling hand movement
Press and hold the Left/Right Hand Control Key (default: Left Shift/Space for left/right respectively) to gain control of either hand. While the manipulation key is pressed, the hand will appear in the viewport. Once the manipulation key is released the hands will disappear after a short Hand Hide Timeout.
Hands can be toggle on permanently in the input simulation tools window or by pressing the Toggle Left/Right Hand Key (default: T/Y for left/right respectively). Press the toggle key again to hide the hands again.
Mouse movement will move the hand in the view plane. Hands can be moved further or closer to the camera using the mouse wheel.
To rotate hands using the mouse, hold both the Left/Right Hand Control Key (shift/space) and the Hand Rotate Button (default: right mouse button). Hand rotation speed can be configured by changing the Mouse Hand Rotation Speed setting in the input simulation profile.
All hand placement can also changed in the input simulation tools window, including resetting hands to default.
Additional profile settings
- Hand Depth Multiplier controls the sensitivity of the mouse scroll wheel depth movement. A larger number will speed up hand zoom.
- Default Hand Distance is the initial distance of hands from the camera. Clicking the Reset button hands will also place hands at this distance.
- Hand Jitter Amount adds random motion to hands. This can be used to simulate inaccurate hand tracking on device, and ensure that interactions work well with noisy input.
Hand gestures such as pinching, grabbing, poking, etc. can also be simulated.
First enable hand control using the manipulation keys (Left Shift/Space)
Alternatively toggle the hands on/off using the toggle keys (T/Y).
While manipulating, press and hold a mouse button to perform a hand gesture.
Each of the mouse buttons can be mapped to transform the hand shape into a different gesture using the Left/Middle/Right Mouse Hand Gesture settings. The Default Hand Gesture is the shape of the hand when no button is pressed.
The Pinch gesture is the only gesture that performs the "Select" action at this point.
- Press and hold hand control key (Space/Left Shift)
- Point at object
- Hold mouse button to pinch
- Use mouse to move the object
- Release mouse button to stop interaction
For manipulating objects with two hands at the same time the persistent hand mode is recommended.
- Toggle on both hands by pressing the toggle keys (T/Y).
- Manipulate one hand at a time:
- Hold Space to control the right hand
- Move the hand to where you want to grab the object
- Press mouse button to activate the Pinch gesture. In persistent mode the gesture will remain active when you release the mouse button.
- Repeat the process with the other hand, grabbing the same object in a second spot.
- Now that both hands are grabbing the same object, you can move either of them to perform two-handed manipulation.
- Enable GGV simulation by switching Hand Simulation Mode to Gestures in the Input Simulation Profile
- Rotate the camera to point the gaze cursor at the interactable object (right mouse button)
- Hold Space to control the right hand
- Click and hold left mouse button to interact
- Rotate the camera again to manipulate the object
Eye tracking simulation can be enabled by checking the Simulate Eye Position option in the Input Simulation Profile. This should not be used with GGV style interactions (so ensure that Hand Simulation Mode is set to Articulated).