- Home /
How do I set an Android applications resolution?
How do I set the resolution for a Unity Android application?
Answer by tnetennba · Mar 18, 2011 at 03:58 PM
You can set the resolution of your application by calling Screen.SetResolution which is documented here:
http://unity3d.com/support/documentation/ScriptReference/Screen.SetResolution.html
If you add this to a scripts start function and attach it to the Main Camera this will force the application to display full screen at a given resolution.
Answer by PawelSandra · Mar 21, 2015 at 06:35 PM
Here is what worked for me and although I am still learning Unity, this seems convenient:
I have set up my scene using canvas as per this tutorial: https://www.youtube.com/watch?v=sTJyJvHZZ1I
Then select Canvas in Hierarchy (instead of camera), then in the Inspector:
Canvas > Render Mode > Screen space - Overlay
Canvas Scaler (Script) > Ui Scale Mode > Scale with screen size
Canvas Scaler (Script) > Reference Resolution > e.g. 800 x 600 (or whatever size works for you best)
I hope this helps somebody.
Answer by Lav-patel · Sep 19, 2012 at 07:52 AM
Void OnGUI() { GUI.matrix = Matrix4x4.TRS(Vector3.zero, Quaternion.identity, new Vector3(1.0f Screen.width / 1024, 1.0f Screen.height / 768, 1)); . . . . }
Answer by LilGames · Oct 26, 2021 at 07:10 PM
There is also DPI and resolution scaling to consider, as detailed here: https://docs.unity3d.com/2018.4/Documentation/Manual/class-PlayerSettingsAndroid.html and here: https://docs.unity3d.com/ScriptReference/QualitySettings-resolutionScalingFixedDPIFactor.html
I haven't quite figured it out yet, but those affect whether the device attempts to render to every pixel available (eg: every pixel availabe in a 4K screen) or scales up a lower-resolution buffer to the final screen output (eg: rendered to 1920x1080 then scaled to the screen display).