GUI Resolution scale not working

Hi!:wink: I’ve been googling this for a while but can’t get it to work.

I have an option to set my game in Fullscreen mode, the problem is that when I do that the GUI items (GUI TExts and GUI Textures) are anchored right, but the scale is the original.

What I was doing is to call this…

Vector2resizeRatio = newVector2((float)Screen.width / screenWidth, (float)Screen.height / screenHeight);
GUI.matrix = Matrix4x4.TRS(Vector3.zero, Quaternion.identity, newVector3(resizeRatio.x, resizeRatio.y, 1.0f));

//screenWidth and screenHeight is the original screen with I designed the GUI

… when I change the resolution by Screen.SetResolution (Screen.currentResolution.width, Screen.currentResolution.height, true); but nothing happens.

Any idea?

Thanks!

Irony being what it is. The solution to your issue is part of the code I submitted when asking about a weird index increment issue I am seeing. To correctly scale for multi res in the gui use this code

 scale.x = Screen.width/originalWidth; // calculate hor scale
        scale.y = Screen.height/originalHeight; // calculate vert scale
        scale.z = 1.0f;
        int index = 0;
        Matrix4x4 svMat = GUI.matrix; // save current matrix
        // substitute matrix - only scale is altered from standard
        GUI.matrix = Matrix4x4.TRS(Vector3.zero, Quaternion.identity, scale);