Cinemachine Problem

I am using Cinemachine 2D with a Confiner but if my screen size grows (Maximize on Play or Build) its not showing the full content like its zooming in so i found a script for fix that. It fixed a bit but its not fully okay, its okay in width but its not okay in height there is a huge empty place down my ground and I dont know how to fix it.

Maximize on Play:

Build:

Script:
public class CameraResize : MonoBehaviour
{
public int fullWidthUnits;

void Start () {
float ratio = (float)Screen.height / (float)Screen.width;
GetComponent
().m_Lens.OrthographicSize = (float)fullWidthUnits * ratio / 2.0f;
}
}

Hi,

I am guessing that your screen size is bigger than the confining area, so that the camera window cannot be confined.
What if you change the screen size in the editor to the same as your screen size at build?

For a better solution in the case when the camera window size is bigger than the confining area, you can use the new CinemachineConfiner2D extension. This new extension will centralize your camera in this case.

6737107--776050--Screen Shot 2021-01-18 at 10.21.55 AM.png

1 Like