Class InputAxisControllerBase<T>
This is a base class for a behaviour that is used to drive IInputAxisOwner behaviours, which it discovers dynamically. It is the bridge between the input system and Cinemachine cameras that require user input. Add it to a Cinemachine camera that needs it. If you want to read inputs from a third-party source, then you must specialize this class with an appropriate implementation of IInputAxisReader.
Implements
Inherited Members
Namespace: Unity.Cinemachine
Assembly: Unity.Cinemachine.dll
Syntax
[ExecuteAlways]
public abstract class InputAxisControllerBase<T> : MonoBehaviour, IInputAxisController where T : IInputAxisReader, new()
Type Parameters
| Name | Description |
|---|---|
| T | The axis reader that will read the inputs. |
Fields
IgnoreTimeScale
If set, then input will be processed using unscaled deltaTime, and not scaled deltaTime. This allows input to continue even when the timescale is set to 0.
Declaration
public bool IgnoreTimeScale
Field Value
| Type | Description |
|---|---|
| bool |
ScanRecursively
If set, a recursive search for IInputAxisOwners behaviours will be performed. Otherwise, only behaviours attached directly to this GameObject will be considered, and child objects will be ignored.
Declaration
[Tooltip("If set, a recursive search for IInputAxisOwners behaviours will be performed. Otherwise, only behaviours attached directly to this GameObject will be considered, and child objects will be ignored")]
public bool ScanRecursively
Field Value
| Type | Description |
|---|---|
| bool |
SuppressInputWhileBlending
If set, input will not be processed while the Cinemachine Camera is participating in a blend.
Declaration
[HideIfNoComponent(typeof(CinemachineVirtualCameraBase))]
[Tooltip("If set, input will not be processed while the Cinemachine Camera is participating in a blend.")]
public bool SuppressInputWhileBlending
Field Value
| Type | Description |
|---|---|
| bool |
Properties
Controllers
This list is dynamically populated based on the discovered axes
Declaration
public List<InputAxisControllerBase<T>.Controller> Controllers { get; }
Property Value
| Type | Description |
|---|---|
| List<InputAxisControllerBase<T>.Controller> |
Methods
ControllersAreValid()
Available in Editor only. Used to check if a controller synchronization is necessary. Normally we should have one controller per IInputAxisOwner axis.
Declaration
public bool ControllersAreValid()
Returns
| Type | Description |
|---|---|
| bool | True if there is one controller defined per IInputAxisOwner axis, false if there is a mismatch |
GetController(string)
Get the controller for a given axis name. The axis name is the name displayed for the axis foldout on the inspector.
Declaration
public InputAxisControllerBase<T>.Controller GetController(string axisName)
Parameters
| Type | Name | Description |
|---|---|---|
| string | axisName | The name of the axis, as it appears in the inspector. |
Returns
| Type | Description |
|---|---|
| InputAxisControllerBase<T>.Controller | The first Controller object with the matching axis name, or null if not found. |
InitializeControllerDefaultsForAxis(in AxisDescriptor, Controller)
Creates default controllers for an axis. Override this if the default axis controllers do not fit your axes.
Declaration
protected virtual void InitializeControllerDefaultsForAxis(in IInputAxisOwner.AxisDescriptor axis, InputAxisControllerBase<T>.Controller controller)
Parameters
| Type | Name | Description |
|---|---|---|
| IInputAxisOwner.AxisDescriptor | axis | Description of the axis whose default controller needs to be set. |
| InputAxisControllerBase<T>.Controller | controller | Controller to drive the axis. |
OnDisable()
Called by Unity when the inspector component is disabled
Declaration
protected virtual void OnDisable()
OnEnable()
Called by Unity when the inspector component is enabled
Declaration
protected virtual void OnEnable()
OnValidate()
Editor only: Called by Unity when the component is serialized or the inspector is changed.
Declaration
protected virtual void OnValidate()
Reset()
Called by Unity when the component is reset.
Declaration
protected virtual void Reset()
SynchronizeControllers()
Normally we should have one controller per IInputAxisOwner axis. This will create missing controllers (in their default state) and remove any that are no longer relevant. This is costly - do not call it every frame.
Declaration
public void SynchronizeControllers()
TriggerRecentering(string)
Triggers recentering for a given axis, and also cancels any input currently in progress for that axis. This ensures that the recentering begins immediately.
Declaration
public bool TriggerRecentering(string axisName)
Parameters
| Type | Name | Description |
|---|---|---|
| string | axisName | The name of the axis, as it appears in the inspector. |
Returns
| Type | Description |
|---|---|
| bool | True if the axis was found and recentering triggered, false otherwise |
UpdateControllers()
Read all the controllers and process their input. Default implementation calls UpdateControllers(IgnoreTimeScale ? Time.unscaledDeltaTime : Time.deltaTime)
Declaration
protected void UpdateControllers()
UpdateControllers(float)
Read all the controllers and process their input.
Declaration
protected void UpdateControllers(float deltaTime)
Parameters
| Type | Name | Description |
|---|---|---|
| float | deltaTime | The time interval for which to process the input |