An asset containing action maps and control schemes.
Inheritance
System.Object
InputActionAsset
public class InputActionAsset : ScriptableObject, ICloneable, IInputActionCollection, IEnumerable<InputAction>
Fields
Declaration
public const string kExtension = "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
Type |
Description |
System.Nullable<ReadOnlyArray<InputDevice>> |
|
Implements
Methods
Add an action map to the asset.
Declaration
public void AddActionMap(InputActionMap map)
Parameters
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 name)
Parameters
Type |
Name |
Description |
System.String |
name |
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.
|
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.
Declaration
public InputActionMap GetActionMap(Guid id)
Parameters
Type |
Name |
Description |
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
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 name)
Parameters
Type |
Name |
Description |
System.String |
name |
|
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 InputActionMap TryGetActionMap(Guid id)
Parameters
Type |
Name |
Description |
Guid |
id |
|
Returns
Declaration
public InputActionMap TryGetActionMap(string name)
Parameters
Type |
Name |
Description |
System.String |
name |
|
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 |
|