GUI Buttons scaling with resolution - help

Hello everyone,

I have another problem.

I'm trying to make the GUI Buttons and Volume Slider I have created scale with the resolution so that it stays in the same place on the screen no matter what resolution you have.

I have pretty much zero experience in js and it's taken me a couple of hours to even get this far:

function OnGUI () {
    if (GUI.Button (Rect (370, 240, 180, 30), "Low")) {
    }

    if (GUI.Button (Rect (555, 240, 180, 30), "Medium")) {
    }

    if (GUI.Button (Rect (740, 240, 180, 30), "High")) {
    }
}

This simply displays the GUI buttons, how do I make them scale?

Thanks

What you need is a GUI that is independent from resolution. Put below line at every of your OnGUI function. And set your own standard resolution values.

var standardResolutionX:float= 1024;
var standardResolutionY:float= 768;

function OnGUI () {
    GUI.matrix = Matrix4x4.TRS (Vector3(0, 0, 0), Quaternion.identity, Vector3(Screen.width / standardResolutionX, Screen.height /standardResolutionY, 1));

    if (GUI.Button (Rect (370, 240, 180, 30), "Low")) {
    }

    if (GUI.Button (Rect (555, 240, 180, 30), "Medium")) {
    }

    if (GUI.Button (Rect (740, 240, 180, 30), "High")) {
    }
}

This works, however it only seems to scale correctly on the X axis (screenwidth). The buttons are still not scaling on Y