using Cinemachine; using Level; using UnityEngine; using UnityEngine.U2D; namespace Camera { public class CameraPlayerFinder : MonoBehaviour { [SerializeField] private int FixedResolutionX = 426; [SerializeField] private int FixedResolutionY = 240; [SerializeField] private int FollowResolutionX = 278; [SerializeField] private int FollowResolutionY = 162; private CinemachineVirtualCamera _cinemachineVirtualCamera; private PixelPerfectCamera pixelPerfectCamera = null; private void Awake() { _cinemachineVirtualCamera = GetComponent(); pixelPerfectCamera = GameObject.FindObjectOfType(); } private void Update() { if (LevelManager.Instance.CurrentLevel?.FixedCameraPoint == null) { if (_cinemachineVirtualCamera.Follow == null) { _cinemachineVirtualCamera.Follow = LevelManager.Instance.Player.transform; pixelPerfectCamera.refResolutionX = FollowResolutionX; pixelPerfectCamera.refResolutionY = FollowResolutionY; } } else if (_cinemachineVirtualCamera.Follow != LevelManager.Instance.CurrentLevel.FixedCameraPoint) { _cinemachineVirtualCamera.Follow = LevelManager.Instance.CurrentLevel.FixedCameraPoint; pixelPerfectCamera.refResolutionX = FixedResolutionX; pixelPerfectCamera.refResolutionY = FixedResolutionY; } } } }