An asset containing action maps and control schemes.
Inheritance
System.Object
InputActionAsset
 
public class InputActionAsset : ScriptableObject, ICloneable, IInputActionCollection, IEnumerable<InputAction>, IEnumerable
 
Fields
  
Declaration
public const string Extension = "inputactions"
 
Field Value
| Type | Description | 
| System.String |  | 
Properties
  
List of action maps defined in the asset.
Declaration
public ReadOnlyArray<InputActionMap> actionMaps { get; }
 
Property Value
Optional mask applied to all bindings in the collection.
Declaration
public InputBinding? bindingMask { get; set; }
 
Property Value
Implements
List of control schemes defined in the asset.
Declaration
public ReadOnlyArray<InputControlScheme> controlSchemes { get; }
 
Property Value
Implements
Devices to use with the actions in this collection.
Declaration
public ReadOnlyArray<InputDevice>? devices { get; set; }
 
Property Value
Implements
True if any action in the asset is currently enabled.
Declaration
public bool enabled { get; }
 
Property Value
| Type | Description | 
| System.Boolean |  | 
Declaration
public InputAction this[string actionNameOrId] { get; }
 
Parameters
| Type | Name | Description | 
| System.String | actionNameOrId |  | 
Property Value
Methods
  
Add an action map to the asset.
Declaration
public void AddActionMap(InputActionMap map)
 
Parameters
Exceptions
| Type | Condition | 
| System.ArgumentNullException | mapisnull.
 | 
| System.InvalidOperationException | maphas no name or asset already contains a
    map with the same name.
 | 
Declaration
public void AddControlScheme(InputControlScheme controlScheme)
 
Parameters
Declaration
public InputActionAsset Clone()
 
Returns
| Type | Description | 
| InputActionAsset | A new asset that contains a duplicate of all action maps and actions in the asset. | 
Declaration
public bool Contains(InputAction action)
 
Parameters
Returns
| Type | Description | 
| System.Boolean |  | 
Implements
Declaration
Implements
Declaration
Implements
Declaration
public InputAction FindAction(string actionNameOrId)
 
Parameters
| Type | Name | Description | 
| System.String | actionNameOrId | Name of the action as either a "map/action" combination (e.g. "gameplay/fire") or
a simple name. In the former case, the name is split at the '/' slash and the first part is used to find
a map with that name and the second part is used to find an action with that name inside the map. In the
latter case, all maps are searched in order and the first action that has the given name in any of the maps
is returned. Note that name comparisons are case-insensitive. Alternatively, the given string can be a GUID as given by id. | 
Returns
| Type | Description | 
| InputAction | The action with the corresponding name or null if no matching action could be found. | 
var asset = ScriptableObject.CreateInstance<InputActionAsset>();
var map1 = new InputActionMap("map1");
var map2 = new InputActionMap("map2");
asset.AddActionMap(map1);
asset.AddActionMap(map2);
var action1 = map1.AddAction("action1");
var action2 = map1.AddAction("action2");
var action3 = map2.AddAction("action3");
// Search all maps in the asset for any action that has the given name.
asset.FindAction("action1") // Returns action1.
asset.FindAction("action2") // Returns action2
asset.FindAction("action3") // Returns action3.
// Search for a specific action in a specific map.
asset.FindAction("map1/action1") // Returns action1.
asset.FindAction("map2/action2") // Returns action2.
asset.FindAction("map3/action3") // Returns action3.
Search by unique action ID.
asset.FindAction(action1.id.ToString()) // Returns action1.
asset.FindAction(action2.id.ToString()) // Returns action2.
asset.FindAction(action3.id.ToString()) // Returns action3.
Exceptions
| Type | Condition | 
| System.ArgumentNullException | actionNameOrIdis null or empty.
 | 
Declaration
public static InputActionAsset FromJson(string json)
 
Parameters
| Type | Name | Description | 
| System.String | json |  | 
Returns
Declaration
public InputActionMap GetActionMap(Guid id)
 
Parameters
| Type | Name | Description | 
| System.Guid | id |  | 
Returns
Declaration
public InputActionMap GetActionMap(string name)
 
Parameters
| Type | Name | Description | 
| System.String | name |  | 
Returns
Declaration
public InputControlScheme GetControlScheme(string name)
 
Parameters
| Type | Name | Description | 
| System.String | name |  | 
Returns
Declaration
public int GetControlSchemeIndex(string name)
 
Parameters
| Type | Name | Description | 
| System.String | name |  | 
Returns
| Type | Description | 
| System.Int32 |  | 
Declaration
public IEnumerator<InputAction> GetEnumerator()
 
Returns
| Type | Description | 
| System.Collections.Generic.IEnumerator<InputAction> |  | 
Replace the contents of the asset with the data in the given JSON string.
Declaration
public void LoadFromJson(string json)
 
Parameters
| Type | Name | Description | 
| System.String | json |  | 
Declaration
public void RemoveActionMap(string nameOrId)
 
Parameters
| Type | Name | Description | 
| System.String | nameOrId |  | 
Declaration
public void RemoveActionMap(InputActionMap map)
 
Parameters
Declaration
public void RemoveControlScheme(string name)
 
Parameters
| Type | Name | Description | 
| System.String | name |  | 
Return a JSON representation of the asset.
Declaration
Returns
| Type | Description | 
| System.String | A string in JSON format that represents the static/configuration data present
in the asset. | 
Declaration
public InputAction TryGetAction(Guid guid)
 
Parameters
| Type | Name | Description | 
| System.Guid | guid |  | 
Returns
Declaration
public InputActionMap TryGetActionMap(Guid id)
 
Parameters
| Type | Name | Description | 
| System.Guid | id |  | 
Returns
Declaration
public InputActionMap TryGetActionMap(string nameOrId)
 
Parameters
| Type | Name | Description | 
| System.String | nameOrId |  | 
Returns
Declaration
public InputControlScheme? TryGetControlScheme(string name)
 
Parameters
| Type | Name | Description | 
| System.String | name |  | 
Returns
Declaration
public int TryGetControlSchemeIndex(string name)
 
Parameters
| Type | Name | Description | 
| System.String | name |  | 
Returns
| Type | Description | 
| System.Int32 |  | 
Extension Methods