This class represents a single action that may have multiple controls bound to it. A bound control is represented by a subclass of BindingSource. For example, DeviceBindingSource provides input from a control on any supported InputDevice. Similarly, KeyBindingSource provides input from one or more keypresses. An action may have any number of bindings. Actions have two groups of bindings defined: default bindings and regular bindings. Default bindings are the predefined default bindings, and the current bindings for the action can be reset to this group in a single operation. Regular bindings are those added by users, most likely at runtime in a settings menu or the like. There are no other distinctions between these groupings; they are purely for organizational convenience. More...
Public Member Functions | |
PlayerAction (string name, PlayerActionSet owner) | |
Construct an action belonging to a given action set. More... | |
void | AddDefaultBinding (BindingSource binding) |
Adds a default binding for the action. This will also add it to the regular bindings. More... | |
void | AddDefaultBinding (params Key[] keys) |
A convenience method for adding a KeyBindingSource to the default bindings. More... | |
void | AddDefaultBinding (KeyCombo keyCombo) |
A convenience method for adding a KeyBindingSource to the default bindings. More... | |
void | AddDefaultBinding (Mouse control) |
A convenience method for adding a MouseBindingSource to the default bindings. More... | |
void | AddDefaultBinding (InputControlType control) |
A convenience method for adding a DeviceBindingSource to the default bindings. More... | |
bool | AddBinding (BindingSource binding) |
Add a regular binding to the action. A binding cannot be added if it matches an existing binding on the action, or if it is already bound to another action. More... | |
bool | InsertBindingAt (int index, BindingSource binding) |
Insert a regular binding to the action at the specified index. A binding cannot be inserted if it matches an existing binding on the action, or if it is already bound to another action. More... | |
bool | ReplaceBinding (BindingSource findBinding, BindingSource withBinding) |
Add a regular binding to the action replacing an existing binding. A binding cannot be added if is already bound to another action. If the binding to replace is not present on this action, the binding will not be added. More... | |
bool | HasBinding (BindingSource binding) |
Searches all the bindings on this action to see if any that match the provided binding object. More... | |
BindingSource | FindBinding (BindingSource binding) |
Searches all the bindings on this action to see if any that match the provided binding object and, if found, returns it. More... | |
void | RemoveBinding (BindingSource binding) |
Searches all the bindings on this action to see if any that match the provided binding object and, if found, removes it. NOTE: the action is only marked for removal, and is not immediately removed. This is to allow for safe removal during iteration over the Bindings collection. More... | |
void | RemoveBindingAt (int index) |
Removes the binding at the specified index from the action. Note: the action is only marked for removal, and is not immediately removed. This is to allow for safe removal during iteration over the Bindings collection. More... | |
void | ClearBindings () |
Clears the bindings for this action. More... | |
void | ResetBindings () |
Resets the bindings to the default bindings. More... | |
void | ListenForBinding () |
Begin listening for a new user defined binding. Which types of BindingSource are detected depends on the value of ListenOptions and DefaultListenOptions. Once one is found, it will be added to the regular bindings for the action and listening will stop. More... | |
void | ListenForBindingReplacing (BindingSource binding) |
Begin listening for a new user defined binding, replacing an existing specified binding. If the binding to replace is not present on this action, the new binding will fail to be added. Which types of BindingSource are detected depends on the value of ListenOptions and DefaultListenOptions. Once one is found, it will be added to the regular bindings for the action and listening will stop. More... | |
void | StopListeningForBinding () |
Stop listening for new user defined bindings. More... | |
![]() | |
bool | UpdateWithState (bool state, ulong updateTick, float deltaTime) |
bool | UpdateWithValue (float value, ulong updateTick, float deltaTime) |
void | ClearInputState () |
void | Commit () |
void | CommitWithState (bool state, ulong updateTick, float deltaTime) |
void | CommitWithValue (float value, ulong updateTick, float deltaTime) |
Public Attributes | |
BindingListenOptions | ListenOptions = null |
Configures how this action listens for new bindings. When null (default) the owner's PlayerActionSet.ListenOptions will be used.
| |
BindingSourceType | LastInputType = BindingSourceType.None |
The binding source type that last provided input to this action. 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. More... | |
InputDeviceStyle | LastDeviceStyle = InputDeviceStyle.Unknown |
The InputDeviceStyle of the binding source that last provided input to this action. More... | |
![]() | |
float | FirstRepeatDelay = 0.8f |
float | RepeatDelay = 0.1f |
bool | Raw |
Properties | |
string | Name [get] |
The unique identifier for this action within the context of its owning action set. More... | |
PlayerActionSet | Owner [get] |
Gets the owning action set containing this action. More... | |
object | UserData [get, set] |
This property can be used to store whatever arbitrary game data you want on this action. More... | |
bool | IsListeningForBinding [get] |
Gets a value indicating whether this action is listening for new user defined bindings. More... | |
ReadOnlyCollection< BindingSource > | Bindings [get] |
Gets the valid (in context of the current device) bindings for this action as a readonly collection. What this means is, if your current active controller is an Xbox One controller and you have InputControlType.Options bound, it will not be included. This is generally the bindings you should display unless you are doing something custom. More... | |
ReadOnlyCollection< BindingSource > | UnfilteredBindings [get] |
Gets ALL bindings for this action (including ones that don't make sense for the current device) as a readonly collection. Use of this collection is not recommended unless you really need unfettered access to all the bindings on an action. 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 this action. When LastInputType is not a device (controller), this will return the null device. More... | |
new float | LowerDeadZone [get, set] |
new float | UpperDeadZone [get, set] |
![]() | |
ulong | UpdateTick [get, protected set] |
bool | State [get] |
bool | LastState [get] |
float? | Value [get] |
float? | LastValue [get] |
float? | RawValue [get] |
bool | HasChanged [get] |
bool | IsPressed [get] |
bool | WasPressed [get] |
bool | WasReleased [get] |
bool | WasRepeated [get] |
float | Sensitivity [get, set] |
float | LowerDeadZone [get, set] |
float | UpperDeadZone [get, set] |
float | StateThreshold [get, set] |
bool | IsNullControl [get] |
bool | Enabled [get, set] |
bool | EnabledInHierarchy [get] |
![]() | |
bool | HasChanged [get] |
bool | IsPressed [get] |
bool | WasPressed [get] |
bool | WasReleased [get] |
Events | |
Action< BindingSourceType > | OnLastInputTypeChanged |
This event is triggered when the binding source type that last provided input to this action changes. More... | |
Action | OnBindingsChanged |
This event is triggered if bindings on an action are added or removed. More... | |
Additional Inherited Members | |
![]() | |
static implicit | operator bool (OneAxisInputControl instance) |
static implicit | operator float (OneAxisInputControl instance) |
![]() | |
bool | isNullControl = false |
bool | ownerEnabled = true |
This class represents a single action that may have multiple controls bound to it. A bound control is represented by a subclass of BindingSource. For example, DeviceBindingSource provides input from a control on any supported InputDevice. Similarly, KeyBindingSource provides input from one or more keypresses. An action may have any number of bindings. Actions have two groups of bindings defined: default bindings and regular bindings. Default bindings are the predefined default bindings, and the current bindings for the action can be reset to this group in a single operation. Regular bindings are those added by users, most likely at runtime in a settings menu or the like. There are no other distinctions between these groupings; they are purely for organizational convenience.
PlayerAction | ( | string | name, |
PlayerActionSet | owner | ||
) |
Construct an action belonging to a given action set.
name | A unique identifier for this action within the context of its owning action set. |
owner | The action set to contain (own) this action. |
bool AddBinding | ( | BindingSource | binding | ) |
Add a regular binding to the action. A binding cannot be added if it matches an existing binding on the action, or if it is already bound to another action.
true
, if binding was added, false
otherwise.binding | The BindingSource to add. |
void AddDefaultBinding | ( | BindingSource | binding | ) |
Adds a default binding for the action. This will also add it to the regular bindings.
binding | The BindingSource to add. |
void AddDefaultBinding | ( | InputControlType | control | ) |
A convenience method for adding a DeviceBindingSource to the default bindings.
control | The InputControlType to add. |
void AddDefaultBinding | ( | KeyCombo | keyCombo | ) |
A convenience method for adding a KeyBindingSource to the default bindings.
keyCombo | A KeyCombo for the binding source. |
void AddDefaultBinding | ( | Mouse | control | ) |
A convenience method for adding a MouseBindingSource to the default bindings.
control | The Mouse control to add. |
void AddDefaultBinding | ( | params Key[] | keys | ) |
A convenience method for adding a KeyBindingSource to the default bindings.
keys | A list of one or more keys making up a KeyCombo for the binding source. |
void ClearBindings | ( | ) |
Clears the bindings for this action.
BindingSource FindBinding | ( | BindingSource | binding | ) |
Searches all the bindings on this action to see if any that match the provided binding object and, if found, returns it.
binding | The BindingSource template to search for. |
bool HasBinding | ( | BindingSource | binding | ) |
Searches all the bindings on this action to see if any that match the provided binding object.
true
, if a matching binding is found on this action, false
otherwise.binding | The BindingSource template to search for. |
bool InsertBindingAt | ( | int | index, |
BindingSource | binding | ||
) |
Insert a regular binding to the action at the specified index. A binding cannot be inserted if it matches an existing binding on the action, or if it is already bound to another action.
true
, if binding was inserted, false
otherwise.index | The index at which to insert. |
binding | The BindingSource to insert. |
void ListenForBinding | ( | ) |
Begin listening for a new user defined binding. Which types of BindingSource are detected depends on the value of ListenOptions and DefaultListenOptions. Once one is found, it will be added to the regular bindings for the action and listening will stop.
void ListenForBindingReplacing | ( | BindingSource | binding | ) |
Begin listening for a new user defined binding, replacing an existing specified binding. If the binding to replace is not present on this action, the new binding will fail to be added. Which types of BindingSource are detected depends on the value of ListenOptions and DefaultListenOptions. Once one is found, it will be added to the regular bindings for the action and listening will stop.
void RemoveBinding | ( | BindingSource | binding | ) |
Searches all the bindings on this action to see if any that match the provided binding object and, if found, removes it. NOTE: the action is only marked for removal, and is not immediately removed. This is to allow for safe removal during iteration over the Bindings collection.
binding | The BindingSource template to search for. |
void RemoveBindingAt | ( | int | index | ) |
Removes the binding at the specified index from the action. Note: the action is only marked for removal, and is not immediately removed. This is to allow for safe removal during iteration over the Bindings collection.
index | The index of the BindingSource in the Bindings collection to remove. |
bool ReplaceBinding | ( | BindingSource | findBinding, |
BindingSource | withBinding | ||
) |
Add a regular binding to the action replacing an existing binding. A binding cannot be added if is already bound to another action. If the binding to replace is not present on this action, the binding will not be added.
true
, if binding was added, false
otherwise.findBinding | The BindingSource to replace. |
withBinding | The BindingSource to replace it with. |
void ResetBindings | ( | ) |
Resets the bindings to the default bindings.
void StopListeningForBinding | ( | ) |
Stop listening for new user defined bindings.
InputDeviceClass LastDeviceClass = InputDeviceClass.Unknown |
The InputDeviceClass of the binding source that last provided input to this action.
InputDeviceStyle LastDeviceStyle = InputDeviceStyle.Unknown |
The InputDeviceStyle of the binding source that last provided input to this action.
BindingSourceType LastInputType = BindingSourceType.None |
The binding source type that last provided input to this action.
ulong LastInputTypeChangedTick |
Updated when LastInputType changes.
BindingListenOptions ListenOptions = null |
Configures how this action listens for new bindings. When null
(default) the owner's PlayerActionSet.ListenOptions will be used.
|
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 this action. When LastInputType is not a device (controller), this will return the null device.
|
get |
Gets the valid (in context of the current device) bindings for this action as a readonly collection. What this means is, if your current active controller is an Xbox One controller and you have InputControlType.Options bound, it will not be included. This is generally the bindings you should display unless you are doing something custom.
|
get |
Gets a value indicating whether this action is listening for new user defined bindings.
|
get |
The unique identifier for this action within the context of its owning action set.
|
get |
Gets the owning action set containing this action.
|
get |
Gets ALL bindings for this action (including ones that don't make sense for the current device) as a readonly collection. Use of this collection is not recommended unless you really need unfettered access to all the bindings on an action.
|
getset |
This property can be used to store whatever arbitrary game data you want on this action.
Action OnBindingsChanged |
This event is triggered if bindings on an action are added or removed.
Action<BindingSourceType> OnLastInputTypeChanged |
This event is triggered when the binding source type that last provided input to this action changes.