InControl API Reference
PlayerActionSet Class Reference

An action set represents a set of actions, usually for a single player. This class must be subclassed to be used. An action set can contain both explicit, bindable single value actions (for example, "Jump", "Left" and "Right") and implicit, aggregate actions which combine together other actions into one or two axes, for example "Move", which might consist of "Left", "Right", "Up" and "Down" filtered into a single two-axis control with its own applied circular deadzone, queryable vector value, etc. More...

Public Member Functions

void Destroy ()
 Properly dispose of this action set. You should make sure to call this when the action set will no longer be used or it will result in unnecessary internal processing every frame. More...
 
PlayerAction GetPlayerActionByName (string actionName)
 Gets the action with the specified action name. If the action does not exist, it returns null. More...
 
void Reset ()
 Reset the bindings on all actions in this set. More...
 
void ClearInputState ()
 
bool HasBinding (BindingSource binding)
 Searches all the bindings on all the actions on this set to see if any match the provided binding object. More...
 
void RemoveBinding (BindingSource binding)
 Searches all the bindings on all the actions on this set to see if any match the provided binding object and, if found, removes it. More...
 
byte[] SaveData ()
 Returns the state of this action set and all bindings encoded into a byte array that you can save somewhere. Pass this string to LoadData() to restore the state of this action set. More...
 
void LoadData (byte[] data)
 Load a state returned by calling SaveBytes() at a prior time. More...
 
string Save ()
 Returns the state of this action set and all bindings encoded into a string that you can save somewhere. Pass this string to Load() to restore the state of this action set. More...
 
void Load (string data)
 Load a state returned by calling Save() at a prior time. More...
 

Public Attributes

BindingSourceType LastInputType = BindingSourceType.None
 The binding source type that last provided input to this action set. More...
 
ulong LastInputTypeChangedTick
 Updated when LastInputType changes. More...
 
InputDeviceClass LastDeviceClass = InputDeviceClass.Unknown
 The InputDeviceClass of the binding source that last provided input to this action set. More...
 
InputDeviceStyle LastDeviceStyle = InputDeviceStyle.Unknown
 The InputDeviceStyle of the binding source that last provided input to this action set. More...
 

Protected Member Functions

PlayerAction CreatePlayerAction (string name)
 Create an action on this set. This should be performed in the constructor of your PlayerActionSet subclass. More...
 
PlayerOneAxisAction CreateOneAxisPlayerAction (PlayerAction negativeAction, PlayerAction positiveAction)
 Create an aggregate, single-axis action on this set. This should be performed in the constructor of your PlayerActionSet subclass. More...
 
PlayerTwoAxisAction CreateTwoAxisPlayerAction (PlayerAction negativeXAction, PlayerAction positiveXAction, PlayerAction negativeYAction, PlayerAction positiveYAction)
 Create an aggregate, double-axis action on this set. This should be performed in the constructor of your PlayerActionSet subclass. More...
 

Properties

InputDevice Device [get, set]
 Optionally specifies a device which this action set should query from, if applicable. When set to null (default) this action set will try to find an active device when required. More...
 
List< InputDeviceIncludeDevices [get]
 A list of devices which this action set should include when searching for an active device. When empty, all attached devices will be considered. More...
 
List< InputDeviceExcludeDevices [get]
 A list of devices which this action set should exclude when searching for an active device. More...
 
ReadOnlyCollection< PlayerActionActions [get]
 Gets the actions in this action set as a readonly collection. More...
 
ulong UpdateTick [get, protected set]
 The last update tick on which any action in this set changed value. More...
 
bool Enabled [get, set]
 Whether this action set should produce input. Default: true More...
 
bool PreventInputWhileListeningForBinding [get, set]
 The prevent input to all actions while any action in the set is listening for a binding. More...
 
object UserData [get, set]
 This property can be used to store whatever arbitrary game data you want on this action set. More...
 
PlayerAction this[string actionName] [get]
 Gets the action with the specified action name. If the action does not exist, KeyNotFoundException is thrown. More...
 
bool IsListeningForBinding [get]
 Query whether any action in this set is currently listening for a new binding. More...
 
BindingListenOptions?? ListenOptions [get, set]
 Configures how in an action in this set listens for new bindings when the action does not explicitly define its own listen options. More...
 
InputDevice?? ActiveDevice [get]
 Gets the currently active device (controller) if present, otherwise returns a null device which does nothing. The currently active device is defined as the last device that provided input to an action on this set. When LastInputType is not a device (controller), this will return the null device. More...
 

Events

Action< BindingSourceType > OnLastInputTypeChanged
 Occurs when the binding source type that last provided input to this action set changes. More...
 

Detailed Description

An action set represents a set of actions, usually for a single player. This class must be subclassed to be used. An action set can contain both explicit, bindable single value actions (for example, "Jump", "Left" and "Right") and implicit, aggregate actions which combine together other actions into one or two axes, for example "Move", which might consist of "Left", "Right", "Up" and "Down" filtered into a single two-axis control with its own applied circular deadzone, queryable vector value, etc.

Member Function Documentation

◆ CreateOneAxisPlayerAction()

PlayerOneAxisAction CreateOneAxisPlayerAction ( PlayerAction  negativeAction,
PlayerAction  positiveAction 
)
protected

Create an aggregate, single-axis action on this set. This should be performed in the constructor of your PlayerActionSet subclass.

Throttle = CreateOneAxisPlayerAction( Brake, Accelerate );
PlayerOneAxisAction CreateOneAxisPlayerAction(PlayerAction negativeAction, PlayerAction positiveAction)
Create an aggregate, single-axis action on this set. This should be performed in the constructor of y...
Definition: PlayerActionSet.cs:153
Parameters
negativeActionThe action to query for the negative component of the axis.
positiveActionThe action to query for the positive component of the axis.

◆ CreatePlayerAction()

PlayerAction CreatePlayerAction ( string  name)
protected

Create an action on this set. This should be performed in the constructor of your PlayerActionSet subclass.

Parameters
nameA unique identifier for this action within the context of this set.
Exceptions
InControlExceptionThrown when trying to create an action with a non-unique name for this set.

◆ CreateTwoAxisPlayerAction()

PlayerTwoAxisAction CreateTwoAxisPlayerAction ( PlayerAction  negativeXAction,
PlayerAction  positiveXAction,
PlayerAction  negativeYAction,
PlayerAction  positiveYAction 
)
protected

Create an aggregate, double-axis action on this set. This should be performed in the constructor of your PlayerActionSet subclass.

Note that, due to Unity's positive up-vector, the parameter order of negativeYAction and positiveYAction might seem counter-intuitive.

Move = CreateTwoAxisPlayerAction( Left, Right, Down, Up );
PlayerTwoAxisAction CreateTwoAxisPlayerAction(PlayerAction negativeXAction, PlayerAction positiveXAction, PlayerAction negativeYAction, PlayerAction positiveYAction)
Create an aggregate, double-axis action on this set. This should be performed in the constructor of y...
Definition: PlayerActionSet.cs:174
Parameters
negativeXActionThe action to query for the negative component of the X axis.
positiveXActionThe action to query for the positive component of the X axis.
negativeYActionThe action to query for the negative component of the Y axis.
positiveYActionThe action to query for the positive component of the Y axis.

◆ Destroy()

void Destroy ( )

Properly dispose of this action set. You should make sure to call this when the action set will no longer be used or it will result in unnecessary internal processing every frame.

◆ GetPlayerActionByName()

PlayerAction GetPlayerActionByName ( string  actionName)

Gets the action with the specified action name. If the action does not exist, it returns null.

Parameters
actionNameThe name of the action to get.

◆ HasBinding()

bool HasBinding ( BindingSource  binding)

Searches all the bindings on all the actions on this set to see if any match the provided binding object.

Returns
true, if a matching binding is found on any action on this set, false otherwise.
Parameters
bindingThe BindingSource template to search for.

◆ Load()

void Load ( string  data)

Load a state returned by calling Save() at a prior time.

Parameters
dataThe data string.

◆ LoadData()

void LoadData ( byte[]  data)

Load a state returned by calling SaveBytes() at a prior time.

Parameters
dataThe data byte array.

◆ RemoveBinding()

void RemoveBinding ( BindingSource  binding)

Searches all the bindings on all the actions on this set to see if any match the provided binding object and, if found, removes it.

Parameters
bindingThe BindingSource template to search for.

◆ Reset()

void Reset ( )

Reset the bindings on all actions in this set.

◆ Save()

string Save ( )

Returns the state of this action set and all bindings encoded into a string that you can save somewhere. Pass this string to Load() to restore the state of this action set.

◆ SaveData()

byte [] SaveData ( )

Returns the state of this action set and all bindings encoded into a byte array that you can save somewhere. Pass this string to LoadData() to restore the state of this action set.

Member Data Documentation

◆ LastDeviceClass

InputDeviceClass LastDeviceClass = InputDeviceClass.Unknown

The InputDeviceClass of the binding source that last provided input to this action set.

◆ LastDeviceStyle

InputDeviceStyle LastDeviceStyle = InputDeviceStyle.Unknown

The InputDeviceStyle of the binding source that last provided input to this action set.

◆ LastInputType

BindingSourceType LastInputType = BindingSourceType.None

The binding source type that last provided input to this action set.

◆ LastInputTypeChangedTick

ulong LastInputTypeChangedTick

Updated when LastInputType changes.

Property Documentation

◆ Actions

ReadOnlyCollection<PlayerAction> Actions
get

Gets the actions in this action set as a readonly collection.

◆ ActiveDevice

InputDevice?? ActiveDevice
get

Gets the currently active device (controller) if present, otherwise returns a null device which does nothing. The currently active device is defined as the last device that provided input to an action on this set. When LastInputType is not a device (controller), this will return the null device.

◆ Device

InputDevice Device
getset

Optionally specifies a device which this action set should query from, if applicable. When set to null (default) this action set will try to find an active device when required.

◆ Enabled

bool Enabled
getset

Whether this action set should produce input. Default: true

◆ ExcludeDevices

List<InputDevice> ExcludeDevices
get

A list of devices which this action set should exclude when searching for an active device.

◆ IncludeDevices

List<InputDevice> IncludeDevices
get

A list of devices which this action set should include when searching for an active device. When empty, all attached devices will be considered.

◆ IsListeningForBinding

bool IsListeningForBinding
get

Query whether any action in this set is currently listening for a new binding.

◆ ListenOptions

BindingListenOptions?? ListenOptions
getset

Configures how in an action in this set listens for new bindings when the action does not explicitly define its own listen options.

◆ PreventInputWhileListeningForBinding

bool PreventInputWhileListeningForBinding
getset

The prevent input to all actions while any action in the set is listening for a binding.

◆ this[string actionName]

PlayerAction this[string actionName]
get

Gets the action with the specified action name. If the action does not exist, KeyNotFoundException is thrown.

Parameters
actionNameThe name of the action to get.

◆ UpdateTick

ulong UpdateTick
getprotected set

The last update tick on which any action in this set changed value.

◆ UserData

object UserData
getset

This property can be used to store whatever arbitrary game data you want on this action set.

Event Documentation

◆ OnLastInputTypeChanged

Action<BindingSourceType> OnLastInputTypeChanged

Occurs when the binding source type that last provided input to this action set changes.


The documentation for this class was generated from the following file: