I was able to make it so that the buttons scale relative to the size of the screen but the problem is that when they do change size so does the position and spacing. How do I rectify this, I’m pretty new at this and would appreciate any help.
// Update is called once per frame
void Update()
{
horizontalRatio = Screen.width / BASE_WIDTH;
verticalRatio = Screen.height / BASE_HEIGHT;
}
Rect setPositionAndSize(float x, float y, float w, float h)
{
x *= horizontalRatio;
y *= verticalRatio;
w *= horizontalRatio;
h *= verticalRatio;
return new Rect(x,y,w,h);
}
void OnGUI()
{
if (GUI.Button (setPositionAndSize(sbposx, sbposy, sbbottonw, sbbottonh), SwatbotTexture, ""))
{
}
if (GUI.Button (setPositionAndSize(bbposx, bbposy, bbbottonw, bbbottonh), BeakbotTexture, ""))
{
}
}
}