b486678290
Library -Artifacts
27 lines
759 B
C#
27 lines
759 B
C#
using UnityEngine;
|
|
using Cinemachine;
|
|
|
|
/// <summary>
|
|
/// An add-on module for Cinemachine Virtual Camera that locks the camera's Y co-ordinate
|
|
/// </summary>
|
|
[ExecuteAlways]
|
|
[SaveDuringPlay]
|
|
[AddComponentMenu("")] // Hide in menu
|
|
public class CustomLockCameraY : CinemachineExtension
|
|
{
|
|
[Tooltip("Lock the camera's Y position to this value")]
|
|
public float m_YPosition = 10;
|
|
|
|
protected override void PostPipelineStageCallback(
|
|
CinemachineVirtualCameraBase vcam,
|
|
CinemachineCore.Stage stage, ref CameraState state, float deltaTime)
|
|
{
|
|
if (stage == CinemachineCore.Stage.Finalize)
|
|
{
|
|
var pos = state.RawPosition;
|
|
pos.y = m_YPosition;
|
|
state.RawPosition = pos;
|
|
}
|
|
}
|
|
}
|