using UnityEngine; namespace Cinemachine { /// /// An abstract representation of a mutator acting on a Cinemachine Virtual Camera /// [DocumentationSorting(24, DocumentationSortingAttribute.Level.API)] public abstract class CinemachineComponentBase : MonoBehaviour { /// Useful constant for very small floats protected const float Epsilon = Utility.UnityVectorExtensions.Epsilon; /// Get the associated CinemachineVirtualCameraBase public CinemachineVirtualCameraBase VirtualCamera { get { if (m_vcamOwner == null) m_vcamOwner = gameObject.transform.parent.gameObject.GetComponent(); return m_vcamOwner; } } CinemachineVirtualCameraBase m_vcamOwner; /// Returns the owner vcam's Follow target. public Transform FollowTarget { get { CinemachineVirtualCameraBase vcam = VirtualCamera; return vcam == null ? null : vcam.Follow; } } /// Returns the owner vcam's LookAt target. public Transform LookAtTarget { get { CinemachineVirtualCameraBase vcam = VirtualCamera; return vcam == null ? null : vcam.LookAt; } } /// Returns the owner vcam's CameraState. public CameraState VcamState { get { CinemachineVirtualCameraBase vcam = VirtualCamera; return vcam == null ? CameraState.Default : vcam.State; } } /// Returns true if this object is enabled and set up to produce results. public abstract bool IsValid { get; } /// Override this to do such things as offset the RefereceLookAt. /// Base class implementation does nothing. /// Input state that must be mutated public virtual void PrePipelineMutateCameraState(ref CameraState state) {} /// What part of the pipeline this fits into public abstract CinemachineCore.Stage Stage { get; } /// Mutates the camera state. This state will later be applied to the camera. /// Input state that must be mutated /// Delta time for time-based effects (ignore if less than 0) public abstract void MutateCameraState(ref CameraState curState, float deltaTime); /// API for the editor, to process a position drag from the user. /// Base class implementation does nothing. /// The amount dragged this frame public virtual void OnPositionDragged(Vector3 delta) {} } }