Class DeviceExtensions
Namespace: AppMana.ComponentModel
Helper classes for InputSystem devices.
public static class DeviceExtensions
Inheritance
Inherited Members
object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), object.MemberwiseClone(), object.ReferenceEquals(object?, object?), object.ToString()
Methods
AddTo(InputDevice, Component)
When the target component is destroyed, the device is removed.
public static InputDevice AddTo(this InputDevice device, Component target)
Parameters
device InputDevice
input device
target Component
a component in your scene
Returns
InputDevice
the device
AddTo(InputDevice, GameObject)
When the target game object is destroyed, the device is removed.
public static InputDevice AddTo(this InputDevice device, GameObject target)
Parameters
device InputDevice
input device
target GameObject
game object in your scene
Returns
InputDevice
the device
AddTo(InputDevice, ICollection<IDisposable>)
When the target disposable collection, the device is removed.
public static InputDevice AddTo(this InputDevice device, ICollection<IDisposable> target)
Parameters
device InputDevice
input device
target ICollection<IDisposable>
a disposable collection
Returns
InputDevice
the device
FindReference(InputActionAsset, string)
Finds an input action reference for the action with the specified name
public static InputActionReference FindReference(this InputActionAsset actionsAsset, string name)
Parameters
actionsAsset InputActionAsset
name string
Returns
InputActionReference
OnCancelledAsObservable(InputAction)
Observes whenever an action is cancelled
public static IObservable<InputAction.CallbackContext> OnCancelledAsObservable(this InputAction action)
Parameters
action InputAction
the action
Returns
IObservable<InputAction.CallbackContext>
a stream of callback contexts
OnKeyAsObservable(InputAction)
Observes an action whose InputAction.activeControl is a KeyControl and emits the key pressed
public static IObservable<(Key keyCode, int scanCode)> OnKeyAsObservable(this InputAction action)
Parameters
action InputAction
the action
Returns
IObservable<(Key keyCode, int scanCode)>
a tuple of key codes and scan codes
Exceptions
throws when the action's active control is not a KeyControl
OnPerformedAsObservable(InputAction)
Observes whenever the action is performed
public static IObservable<InputAction.CallbackContext> OnPerformedAsObservable(this InputAction action)
Parameters
action InputAction
the action
Returns
IObservable<InputAction.CallbackContext>
a stream of callback contexts
See Also
MultiplayerInputActionReference
OnTextInputAsObservable(Keyboard)
Observes a stream of text character inputs from the provided keyboard using Keyboard.onTextInput
public static IObservable<char> OnTextInputAsObservable(this Keyboard keyboard)
Parameters
keyboard Keyboard
the keyboard
Returns
an observable of characters
OnValueAsObservable<T>(InputAction)
Streams the values from the action whenever it is performed
public static IObservable<T> OnValueAsObservable<T>(this InputAction action) where T : struct
Parameters
action InputAction
the action
Returns
IObservable<T>
a stream of values whenever the action is performed
Type Parameters
T
the type of its value (corresponds to its associated control)
User(CallbackContext)
Get the user associated with the input action callback.
public static InputUser? User(this InputAction.CallbackContext callbackContext)
Parameters
callbackContext InputAction.CallbackContext
Returns
InputUser?
Remarks
Useful for retrieving the user from a performed callback.
