Simulate touches
You can simulate touch input from pointer devices such as mouse and pen devices in the following ways:
- Enable touch simulation in the Unity Editor.
- Add touch simulation to a GameObject.
- Enable touch simulation in startup code.
Enable touch simulation in the Unity Editor
To enable touch simulation in the Unity Editor, perform the following steps:
- Open the Input Debugger (Window > Analysis > Input Debugger)
- Select the Options dropdown, and enable Simulate Touch Input From Mouse or Pen.
Add touch simulation to a GameObject
Add the TouchSimulation MonoBehaviour to a GameObject in your scene. TouchSimulation adds a Touchscreen device and automatically mirrors input on any Pointer device to the virtual touchscreen device.
Enable touch simulation in startup code
Call TouchSimulation.Enable somewhere in your startup code:
void OnEnable()
{
TouchSimulation.Enable();
}