Hi. I’ve tried following the guide here: Input Action Assets | Input System | 1.0.2
But I cannot find any information on how to “Generate Interfaces”. Where’s the checkbox?
Can I use the code in the guide for setting up multiple action maps to listen for inputs?
Example: I have a DEV-action map that listens for F1-F4 buttons and shows/hides developer stuff, while I have a WEAPON-action map that listens for mouse/keyboard inputs.
Using:
Unity 2019.3.0b8
Input System 1.0.0 preview.2
Win10 64bit
I believe they’re talking about the “Generate C# class” option.
Generating the C# class has nothing to do with using multiple action maps. Try to understand the structure of what you’re working with and that’ll give you a clue on how to proceed.
Basically you have the InputActionAsset which is the thing that sits in your Asset folder that you edit to adjust your Actions and bindings. Each InputActionAsset has a list of the Action Maps. Each Action Map has a list of Actions. Each Action has a list of bindings. In the input system, data is acquired either through callbacks set up per-action, or by reading the Action’s “Value” with ReadValue().
When you generate a C# class for the asset, all it does is provide the same structure but with specific named types so that its easier to debug. For example, if your InputActionAsset is named “MyAsset” you will get a class called “MyAsset” with a subclass for each InputActionMap and data within each Map for each action, all named according to how you set it up. So if you want to get the action “F1” from the map “DevMap”, you can just do MyAsset.DevMap.F1 and you’ll get your action. Of course you need a reference to MyAsset in your code, so just make it a public variable and you can drag it in with the inspector. I’m assuming you know how to set up a callback/read the value from an action.
Of course, you don’t need to generate a C# class to just get a certain action. You can have a variable of type InputActionAsset as well and use FindAction() to get a specific action from it. It will come back in the generic Action type, without being named so you don’t have to worry about compiling each time you adjust an input. FindAction() can specify the Map using “/”. So just specify all your actions in each map to be bound to whatever functions you want, or read the value at the appropriate time. I’d say just have a bool somewhere that turns some functions off if you need to restrict maps.
1 Like