GUI Matrix problem

Hi, is there way to scale GUI without aspect ratio deformation? Here’s my matrix code:

GUI.matrix = Matrix4x4.TRS(Vector3.zero,Quaternion.identity,new Vector3(Screen.width/960f,Screen.height/640f,1f));

[11608-výstřižek2.jpg|11608]

If I use Matrix4x4.Scale with same width as height (640), that’s look fine, but can’t be nothing aligned at right side of screen (with Screen.width - xxx etc.)

[11610-výstřižek.jpg|11610]

Can someone help me? And sorry for my bad English, I am Czech. :slight_smile:

You always have aspect problems when the X and Y scales are different. A common solution is to calculate only the vertical scale, and assign it to the horizontal scale as well (or vice versa):

float yScale = Screen.height/640f;
GUI.matrix = Matrix4x4.TRS(Vector3.zero,Quaternion.identity,new Vector3(yScale, yScale, 1f));