Class GameControls
- Namespace
- ProjectL.InputActions
- Assembly
- Assembly-CSharp.dll
Provides programmatic access to UnityEngine.InputSystem.InputActionAsset, UnityEngine.InputSystem.InputActionMap, UnityEngine.InputSystem.InputAction and UnityEngine.InputSystem.InputControlScheme instances defined in asset "Assets/InputActions/GameControls.inputactions".
public class GameControls : IInputActionCollection2, IInputActionCollection, IEnumerable<InputAction>, IEnumerable, IDisposable
- Inheritance
-
GameControls
- Implements
-
IInputActionCollection2IInputActionCollectionIEnumerable<InputAction>
- Inherited Members
Examples
using namespace UnityEngine;
using UnityEngine.InputSystem;
// Example of using an InputActionMap named "Player" from a UnityEngine.MonoBehaviour implementing callback interface.
public class Example : MonoBehaviour, MyActions.IPlayerActions
{
private MyActions_Actions m_Actions; // Source code representation of asset.
private MyActions_Actions.PlayerActions m_Player; // Source code representation of action map.
void Awake()
{
m_Actions = new MyActions_Actions(); // Create asset object.
m_Player = m_Actions.Player; // Extract action map object.
m_Player.AddCallbacks(this); // Register callback interface IPlayerActions.
}
void OnDestroy()
{
m_Actions.Dispose(); // Destroy asset object.
}
void OnEnable()
{
m_Player.Enable(); // Enable all actions within map.
}
void OnDisable()
{
m_Player.Disable(); // Disable all actions within map.
}
#region Interface implementation of MyActions.IPlayerActions
// Invoked when "Move" action is either started, performed or canceled.
public void OnMove(InputAction.CallbackContext context)
{
Debug.Log($"OnMove: {context.ReadValue<Vector2>()}");
}
// Invoked when "Attack" action is either started, performed or canceled.
public void OnAttack(InputAction.CallbackContext context)
{
Debug.Log($"OnAttack: {context.ReadValue<float>()}");
}
#endregion
}
Remarks
This class is source generated and any manual edits will be discarded if the associated asset is reimported or modified.
Constructors
GameControls()
Constructs a new instance.
public GameControls()
Properties
Gameplay
Provides a new GameControls.GameplayActions instance referencing this action map.
public GameControls.GameplayActions Gameplay { get; }
Property Value
UI
Provides a new GameControls.UIActions instance referencing this action map.
public GameControls.UIActions UI { get; }
Property Value
asset
Provides access to the underlying asset instance.
public InputActionAsset asset { get; }
Property Value
- InputActionAsset
bindingMask
public InputBinding? bindingMask { get; set; }
Property Value
- InputBinding?
bindings
public IEnumerable<InputBinding> bindings { get; }
Property Value
- IEnumerable<InputBinding>
controlSchemes
public ReadOnlyArray<InputControlScheme> controlSchemes { get; }
Property Value
- ReadOnlyArray<InputControlScheme>
devices
public ReadOnlyArray<InputDevice>? devices { get; set; }
Property Value
- ReadOnlyArray<InputDevice>?
Methods
Contains(InputAction)
public bool Contains(InputAction action)
Parameters
action
InputAction
Returns
Disable()
public void Disable()
Dispose()
Destroys this asset and all associated UnityEngine.InputSystem.InputAction instances.
public void Dispose()
Enable()
public void Enable()
~GameControls()
protected ~GameControls()
FindAction(string, bool)
public InputAction FindAction(string actionNameOrId, bool throwIfNotFound = false)
Parameters
Returns
- InputAction
FindBinding(InputBinding, out InputAction)
public int FindBinding(InputBinding bindingMask, out InputAction action)
Parameters
bindingMask
InputBindingaction
InputAction
Returns
GetEnumerator()
public IEnumerator<InputAction> GetEnumerator()
Returns
- IEnumerator<InputAction>