Scaling with GUI

Hello , I’m currently working on a GUI and I would like to scale my buttons/windows for the different types of devices

I was thinking of :

w = Screen.width;
h = Screen.height;
if (GUI.Button(new Rect(18, 30, (w/10010), (h/10010)),“”))
** {**

** }**

I would divide the width/length by a 100, to get 1% of the screen. and then I would multiply it by the size i want(Here I used 10% of the screen)

This does not really work though.
Are there any other ways to do this?

Thanks in advance.

Try this, I just answered it today.

What you need to do is:

  1. to use the same scale for width and height of the text, or else you get the aspect ratio change (so use the Min of screen width and height or something similar)
  2. change the font size using the GUI.skin.button.fontSize (because changing the button size doesn’t effect the font size)

Thanks for the reply but it’s not what I’m looking for. Its just the size of the button I want to have scaled with the resolution of the screen(For example different IOS devices) not any text. The way I did it works a little bit but I feel it’s somewhat off

GUI.Button(new Rect(10, 10, Screen.width/10), Screen.height/10, “My Button”)) should really work. Don’t know what is problematic here…

Alright, it just looked off. You’re probably right. thanks for your time dkozar.

I heard that the GUI system is very taxing on mobile devices. Is this still the case considering that devices are more powerfull now? And does it matter if there are only a couple of them on the screen during gameplay?

Thanks in advance.