Question by
Phedg1 · May 07, 2016 at 11:52 AM ·
scalingresolutionsgui.matrix
How To Scale UI Across Multiple Resolutions
I have done some looking around and have often come across this code snippet
float virtualWidth = 1920.0f;
float virtualHeight = 1080.0f;
void OnGUI ()
{
matrix = Matrix4x4.TRS (Vector3.zero, Quaternion.identity, Vector3(Screen.width/virtualWidth, Screen.height/virtualHeight, 1.0f));
GUILayout.Label ("Woo");
}
I am keen to give this a try, but I not been able to get it to work. On which object in my scene to I place this? Do I have to have a canvas set to screen space - camera or something? Thanks in advance for the help.
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612080330im_/https://answers.unity.com/themes/thub/images/avi.jpg)