- Home /
Scaling a quad
I have a quad that is scaled 26.1x10.1 to fill the screen. It has a texture which I scroll to create a background affect. I had to move my ortho camera size to 540(for smooth moves to be pixel perfect at 1920x1080), and I am wondering where I could find some information on doing these calculations so I understand more how things scale and what my quad dimensions would need to be set to so that it fills the screen like before. Thanks.
Answer by robertbu · Feb 26, 2014 at 06:23 AM
The Orthographic size is 1/2 of the vertical size seen by the screen. So if you wanted to scale a quad to exactly fit:
var quadHeight = Camera.main.orthographicSize * 2.0;
The horizontal size is based on the aspect ratio of the screen:
var quadWidth = quadHeight * Screen.width / Screen.height;
So you would then size your Quad to (quadWidth, quadHeight, 1). In code:
transform.localScale = Vector3(quadWidth, quadHeight, 1);
In your case the height would be 540 2.0 = 1080. And the width would be 1080 / 1080 1920 = 1920.
Hmm, it's not exactly filling the screen but it is close. Wonder why it is off. Thanks for the explanation though!
Any change your camera is offset? Your camera needs to have x and y at 0.
I just tested it in the editor (1024 * 768) and it worked perfectly. I've run this test before, but I wanted to be sure my info was accurate. What are you seeing?
As I offered - upload your testscene somewhere, and I can check it.
Your answer
Follow this Question
Related Questions
Make long distance objects visible on camera 0 Answers
Restrict 2D camera with a Quad? 0 Answers
Scale texture of a quad smoothly 1 Answer
How to fix FPS camera to scale of models? 0 Answers
How to create extremely small UI? 0 Answers