Hi there,
How can I create (calculate the size of) a rect that has the exact size of the current camera for a 2D game? I want to use that rect as background that has exactly the same size as the screen.
Thanks in advance
Tosek
Hi there,
How can I create (calculate the size of) a rect that has the exact size of the current camera for a 2D game? I want to use that rect as background that has exactly the same size as the screen.
Thanks in advance
Tosek
You can get the camera’s rect to work with it:
var cam = GetComponent<Camera>();
cam.rect; // Its Rect object
cam.rect.width; // The width of the camera rect, in a float number.
You can also just get the size
Camera cam = Camera.main;
float height = 2f * cam.orthographicSize
float width = height * cam.aspect;
Tnak you guys.