using UnityEngine;
namespace Utility.UIAdapter
{
public class CameraAdapter : MonoBehaviour
{
private float _width;
private float _height;
///
/// 宽高比
///
private float _ratio;
private float _defaultFOV = 50;
private Vector2 _sizeDelta;
///
/// 设计宽高比
///
private float _designRatio;
private Camera _camera;
void Start()
{
_width = Screen.width;
_height = Screen.height;
_ratio = _width / _height;
_designRatio = 1334f / 750f;
_camera = gameObject.GetComponent();
if (_camera.orthographic)
{
_camera.orthographicSize = _designRatio / _ratio * _camera.orthographicSize;
}
else
{
if (_designRatio / _ratio * _defaultFOV < 50)
{
_camera.fieldOfView = 50;
}
else
{
_camera.fieldOfView = _designRatio / _ratio * _defaultFOV;
}
}
}
}
}