- Home /
Screen Resolution Scaling No Solution?
I have searched and searched, but I can't seem to find any way to fix this.
I am creating an android app, and I would like it to just scale to the screen size so the ratio is the same no matter what the screen size is.
With my app it is perfectly ok if things appear stretched.
I just want it to look the exact same as if it were in a 16 by 10 window at 1280 by 800.
HOW CAN I FIX THIS
Answer by robertbu · Feb 09, 2014 at 08:59 PM
You can do what you are asking here by setting up a custom projection matrix for the camera. I've never researched camera projection matrices, so I don't know all the implications of making the change. Example code:
#pragma strict
private var baseAspect : float = 1280.0 / 800.0;
function Start() {
var currAspect : float = 1.0 * Screen.width / Screen.height;
Debug.Log(Camera.main.projectionMatrix);
Debug.Log(baseAspect + ", " + currAspect + ", " + baseAspect / currAspect);
Camera.main.projectionMatrix = Matrix4x4.Scale(Vector3(currAspect / baseAspect, 1.0, 1.0)) * Camera.main.projectionMatrix;
}
That doesn't quite work. $$anonymous$$y camera is orthographic and set to a size of 5. I want everything that that camera sees in it's 5, to be showed on the screen and scaled to the screen.
I had the division backwards. I edited the code above I tested it. It now works as you describe.