There is currently an issue with the interop between the PixelPerfect (main camera) component and the Cinemachine Confiner.
After the scene is loaded, PixelPerfect gets called before it’s initialized and so it reports to Cinemachne an invalid default ortho size. That ortho size is then used to initialize the confiner cache, resulting in an incorrect cache.
You can work around this by invalidating the confiner cache, but you need to do this after the first frame has completed. Here is a script that you can add to the CInemachineCamera that invalidates the cache at the right time.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CameraInitializer : MonoBehaviour
{
private void OnEnable()
{
// Invalidate the confiner cache to ensure it's up to date
var confiner = GetComponent<Cinemachine.CinemachineConfiner2D>();
if (confiner != null)
{
StartCoroutine(InvalidateConfinerCache(confiner));
}
}
private IEnumerator InvalidateConfinerCache(Cinemachine.CinemachineConfiner2D confiner)
{
yield return new WaitForEndOfFrame();
confiner.InvalidateCache();
}
}