Implementing touch with Input System's Enhanced Touch API
This tutorial relies on scripts and models that are included in the starter project. You can download the starter project by:
You’ll see Materials, Models, Prefabs, Scenes, Scripts and a Sprites folder in Assets/WUG. Open the Demo scene in Assets/WUG/Scenes.
Before you can start coding, you need to install the Unity Input system.
Multi-platform games are becoming a staple in the gaming industry. The current input system doesn’t support anything beyond a simple configuration. To fix this, Unity has been overhauling the input system to create a more robust one that better supports multi-platform scenarios. To import it into your project:
Some areas of Unity, such as the Universal Render Pipeline, still need the old input system to function. Luckily, you can have both input systems enabled. To tell Unity to use both input systems, do the following:
The new Input system lets you simulate touch input from other kinds of devices, such as a mouse or pen. While helpful, this approach has two important limitations:
Since you’ll add pinch logic for zooming, which requires two touchpoints, you can’t use simulation mode for this tutorial.
If you’re interested in simulation mode, you can enable it by going to Window ▸ Analysis ▸ Input Debugger. This opens the Input Debug window. In this window, select Options ▸ Simulate Touch from Mouse or Pen.
Now that you have the system installed, you can gather touch input.