using Cinemachine; using UnityEngine; public class DynamicCinemachine : MonoBehaviour { public CinemachineVirtualCamera vCam; public int baseResolutionWidth = 1280; public int baseResolutionHeight = 720; public int pixelsPerUnit = 32; private void Start() { AdjustCameraSize(); } private void Update() { // Optional: Adjust on-the-fly if the screen resolution changes AdjustCameraSize(); } private void AdjustCameraSize() { var targetAspect = Screen.width / (float)Screen.height; var baseAspect = baseResolutionWidth / (float)baseResolutionHeight; var orthographicSize = baseResolutionHeight / (2.0f * pixelsPerUnit) * (baseAspect / targetAspect); vCam.m_Lens.OrthographicSize = orthographicSize; } }