29 lines
831 B
C#
29 lines
831 B
C#
|
using System;
|
|||
|
using Cinemachine;
|
|||
|
using UnityEngine;
|
|||
|
|
|||
|
namespace RND
|
|||
|
{
|
|||
|
public class CameraDistanceCorrector : BaseCameraCorrector
|
|||
|
{
|
|||
|
private CinemachineFramingTransposer _framingTransposer;
|
|||
|
private float _defaultDistance;
|
|||
|
private float _coefficient;
|
|||
|
|
|||
|
protected override void OnInit()
|
|||
|
{
|
|||
|
_framingTransposer = VirtualCamera.GetCinemachineComponent<CinemachineFramingTransposer>();
|
|||
|
if (_framingTransposer == null)
|
|||
|
return;
|
|||
|
|
|||
|
_defaultDistance = _framingTransposer.m_CameraDistance;
|
|||
|
}
|
|||
|
|
|||
|
public override void SyncCameraProperty(float widthOrHeight)
|
|||
|
{
|
|||
|
_coefficient = DefaultRatio / Camera.aspect;
|
|||
|
_framingTransposer.m_CameraDistance = _defaultDistance * _coefficient;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|