Class CinemachineExtension
Base class for a Cinemachine Virtual Camera extension module. Hooks into the Cinemachine Pipeline. Use this to add extra processing to the vcam, modifying its generated state
Inherited Members
Namespace: Cinemachine
Syntax
[DocumentationSorting(DocumentationSortingAttribute.Level.API)]
public abstract class CinemachineExtension : MonoBehaviour
Fields
Epsilon
Useful constant for very small floats
Declaration
protected const float Epsilon = 0.0001F
Field Value
Type | Description |
---|---|
Single |
Properties
RequiresUserInput
Extensions that require user input should implement this and return true.
Declaration
public virtual bool RequiresUserInput { get; }
Property Value
Type | Description |
---|---|
Boolean |
VirtualCamera
Get the CinemachineVirtualCamera to which this extension is attached
Declaration
public CinemachineVirtualCameraBase VirtualCamera { get; }
Property Value
Type | Description |
---|---|
CinemachineVirtualCameraBase |
Methods
Awake()
Connect to virtual camera pipeline. Override implementations must call this base implementation
Declaration
protected virtual void Awake()
ConnectToVcam(Boolean)
Connect to virtual camera. Implementation must be safe to be called redundantly. Override implementations must call this base implementation
Declaration
protected virtual void ConnectToVcam(bool connect)
Parameters
Type | Name | Description |
---|---|---|
Boolean | connect | True if connecting, false if disconnecting |
ForceCameraPosition(Vector3, Quaternion)
Force the virtual camera to assume a given position and orientation
Declaration
public virtual void ForceCameraPosition(Vector3 pos, Quaternion rot)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | pos | Worldspace pposition to take |
Quaternion | rot | Worldspace orientation to take |
GetAllExtraStates<T>()
Inefficient method to get all extra state info for all vcams. Intended for Editor use only, not runtime!
Declaration
protected List<T> GetAllExtraStates<T>()
where T : class, new()
Returns
Type | Description |
---|---|
List<T> | A dynamically-allocated list with all the extra states |
Type Parameters
Name | Description |
---|---|
T | The extra state type |
GetExtraState<T>(ICinemachineCamera)
Because extensions can be placed on manager cams and will in that case be called for all the vcam children, vcam-specific state information should be stored here. Just define a class to hold your state info and use it exclusively when calling this.
Declaration
protected T GetExtraState<T>(ICinemachineCamera vcam)
where T : class, new()
Parameters
Type | Name | Description |
---|---|---|
ICinemachineCamera | vcam | The virtual camera being processed |
Returns
Type | Description |
---|---|
T | The extra state, cast as type T |
Type Parameters
Name | Description |
---|---|
T | The type of the extra state class |
GetMaxDampTime()
Report maximum damping time needed for this extension. Only used in editor for timeline scrubbing.
Declaration
public virtual float GetMaxDampTime()
Returns
Type | Description |
---|---|
Single | Highest damping setting in this extension |
InvokePostPipelineStageCallback(CinemachineVirtualCameraBase, CinemachineCore.Stage, ref CameraState, Single)
Legacy support. This is only here to avoid changing the API to make PostPipelineStageCallback() public
Declaration
public void InvokePostPipelineStageCallback(CinemachineVirtualCameraBase vcam, CinemachineCore.Stage stage, ref CameraState state, float deltaTime)
Parameters
Type | Name | Description |
---|---|---|
CinemachineVirtualCameraBase | vcam | The virtual camera being processed |
CinemachineCore.Stage | stage | The current pipeline stage |
CameraState | state | The current virtual camera state |
Single | deltaTime | The current applicable deltaTime |
OnDestroy()
Disconnect from virtual camera pipeline. Override implementations must call this base implementation
Declaration
protected virtual void OnDestroy()
OnEnable()
Does nothing. It's here for the little checkbox in the inspector.
Declaration
protected virtual void OnEnable()
OnTargetObjectWarped(Transform, Vector3)
This is called to notify the extension that a target got warped, so that the extension can update its internal state to make the camera also warp seamlessy. Base class implementation does nothing.
Declaration
public virtual void OnTargetObjectWarped(Transform target, Vector3 positionDelta)
Parameters
Type | Name | Description |
---|---|---|
Transform | target | The object that was warped |
Vector3 | positionDelta | The amount the target's position changed |
OnTransitionFromCamera(ICinemachineCamera, Vector3, Single)
Notification that this virtual camera is going live. Base class implementation must be called by any overridden method.
Declaration
public virtual bool OnTransitionFromCamera(ICinemachineCamera fromCam, Vector3 worldUp, float deltaTime)
Parameters
Type | Name | Description |
---|---|---|
ICinemachineCamera | fromCam | The camera being deactivated. May be null. |
Vector3 | worldUp | Default world Up, set by the CinemachineBrain |
Single | deltaTime | Delta time for time-based effects (ignore if less than or equal to 0) |
Returns
Type | Description |
---|---|
Boolean | True to request a vcam update of internal state |
PostPipelineStageCallback(CinemachineVirtualCameraBase, CinemachineCore.Stage, ref CameraState, Single)
This callback will be called after the virtual camera has implemented each stage in the pipeline. This method may modify the referenced state. If deltaTime less than 0, reset all state info and perform no damping.
Declaration
protected abstract void PostPipelineStageCallback(CinemachineVirtualCameraBase vcam, CinemachineCore.Stage stage, ref CameraState state, float deltaTime)
Parameters
Type | Name | Description |
---|---|---|
CinemachineVirtualCameraBase | vcam | The virtual camera being processed |
CinemachineCore.Stage | stage | The current pipeline stage |
CameraState | state | The current virtual camera state |
Single | deltaTime | The current applicable deltaTime |
PrePipelineMutateCameraStateCallback(CinemachineVirtualCameraBase, ref CameraState, Single)
Override this to do such things as offset the RefereceLookAt. Base class implementation does nothing.
Declaration
public virtual void PrePipelineMutateCameraStateCallback(CinemachineVirtualCameraBase vcam, ref CameraState curState, float deltaTime)
Parameters
Type | Name | Description |
---|---|---|
CinemachineVirtualCameraBase | vcam | The virtual camera being processed |
CameraState | curState | Input state that must be mutated |
Single | deltaTime | The current applicable deltaTime |