Implementing touch with Input System's Enhanced Touch API
I’ve been playing many strategy games lately, which got me thinking: Wouldn’t it be fun to give the player the ability to build with the new Input System? So, that’s what you’re going to do for the final part of this tutorial! Here’s how it’ll work:
Now, you’ll start by setting up the UI.
The starter project includes a UI prefab with the icons and layout already set up. You only need to add the event logic. First, add the missing game objects to the scene:
The Replace with InputSystemUIInputModule button only appears if the new Input System package is installed.
Before you go any further, lets take a closer look at the Input System UI Input Module.
Input System UI Input Module replaces Standalone Input Module, which is how the legacy input system communicates with the UI. Using the new component lets the new Input System communicate with UI events.
You can read more about the Input System UI Input Module here.
You can configure several properties on the Input System UI Input Module. Here’s a quick explanation of each:
Move is a standard UI event. You can read more about UI events here.
The remaining properties let you map UI events to the input mappings defined in the Action Asset. Here’s a look at the default mapping:
Pointer Behavior determines how the Input System routes input into the UI if many input devices are available. You can choose from three options:
Earlier you changed the Pointer Behavior property from Single Mouse Or Pen But Multi Touch And Track to Single Unified Pointer. I tested on a laptop that has both a mouse and a touch screen. With the default value, I found my touches don’t register on the UI.
Now that you’ve learned how the Input System works with the UI, move on to the fun stuff!