21 lines
459 B
C#
21 lines
459 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
[RequireComponent(typeof(Camera))]
|
|
public class ResponsiveCameraZoom : MonoBehaviour
|
|
{
|
|
public float defaultFov = 4; //FOV at 16:9
|
|
Camera cam;
|
|
|
|
void Awake()
|
|
{
|
|
cam = GetComponent<Camera>();
|
|
}
|
|
void Update()
|
|
{
|
|
float aspectRatio = (float)Screen.height / (float)Screen.width;
|
|
cam.orthographicSize = defaultFov * aspectRatio;
|
|
}
|
|
}
|