Hello, for the screen. how to get size of viewport?
i’m using the orthogonal projection to make 2d game. However i didn’t get the way to identity size of viewport.
Please someone tell me how to get it.
Hello, for the screen. how to get size of viewport?
i’m using the orthogonal projection to make 2d game. However i didn’t get the way to identity size of viewport.
Please someone tell me how to get it.
What do you mean by size? Pixels, Normalized, Ratio? Not sure heh.
Some notes about the Unity Orthogonal camera:
you can check pixel size of a view by using Screen.height and Screen.width
If you changed the view matrix of a camera you can use the cameraObject.pixelRect property to get the rect of the camera in pixels.
If you want a 1:1 pixel-per-unit ratio set your orthogonal camera’s “height” property to half the Screen.height
I personally prefer a 100:1 ratio
ie:
Screen is 1024x768
Camera “Height” is 3.84
this means that a 1x1x1 cube will take up 100x100 pixels if its rotation matches the camera.