Auto Rescale and reposition with ratio and screen resolution. Scripting ?

Hi,

I’m doing a complete viewer for architecture, and I’ve done all my gui in guistyles, with my own textures etc…

I would like to know if there is a proper way to do that:
Rescale and reposition my toolbars and buttons in function of the ratio and the screen resolution. (I can already choose which texture the viewer need to use to have the best quality).

For the moment, to still have the same position (alignment) between buttons and background panels, I use mathematics expressions, using a button size (squares so w = h) and I give them a position from the top - center of the screen for the top toolbar, center-center for the right and left toolbars and bottom-center for the bottom toolbar
Like position = ( screen width /2 + 1/2 buttonWH, screen height/2 - 5buttonWH)
and the next one ( screen width /2 + 5/2 buttonWH, screen height/2 - 5
buttonWH) for example ( with buttonWH = 50px)

So you can imagine the size of the position line of my last button of my right toolbar…

Right now I can with my script select with GUI top toolbar texture should I use in function of the screen ratio, by using a guistyle for each ratio.

I’m not sure it’s cristalclear what i’ve write down there, but the title of the topic should be clear (long long week sorry…)

There’s an explanation of how to do resolution-independent GUI in this thread (and it should eliminate some of those long lines of code :wink: ).

Hi!

Thank’s for your help,

I’m trying your matrix right now and developing all my GUI.

I’ve got a question about the ratios :

I want to create an stand alone without the display resolution dialog. So when you clic on the exe it launch directly the viewer.

My problem is, I’ll send this viewer for many different clients so I don’t know which ratio have their screens:

How can i do to have an exe which at start check the ratio between 16/9 16/10 and 4/3 as close as possible from the actual screen ratio, then use the biggest resolution in this ratio for this screen ?

I don’t want to display the dialog box because my clients don’t know anything about resolution etc…

An another question about autorescale,

To use your matrix, if I’ve understand correctly, I need to configure my ratio (horizRatio, verticRatio) with the highest resolution on the ratio that I choose.
So for example, with a 16/10 ratio, I configure that with a 1920*1200 resolution. and my GUIs will stay the sames for all the 16/10 resolutions.
Is that correct ?
I’m preparing a auto detect screen ratio then choose the right textures and right parameters for position and size of every GUI, between 3 ratio (16/10 16/9 4/3).

When I’m in Unity, in my Game window, when I’m choosing the standalone with my selected resolution(so not the Free Aspect) my GUIs are correctly sized and positioned. But when I maximize on play, all my GUI stay exactly the same between each others but stay with the window resolution, they didn’t grow and stay in the Top Left part of the screen.
Do you have any idea why ? Right know I build and run everytime to check if everything is still good

Thank’s a lot for your help

BooBi

Ok I can detect the ratio, choose textures and parameters for this ratio and create the a viewer which autorescale to stay in the good ratio by using the GUI.matrix.

But I still don’t know how to do for the stand alone (last question)

up!

is it even possible ?

Hi,

Again, I can get working my autodetect ratio for the exe.

I want to create an standalone project, which:

  • start without Display the Resolution dialog.-
  • go fullscreen
  • check the screen size
  • choose the right ratio (between 16/10, 16/9 and 4/3)
  • choose the highest resolution for the screen

Or, I use a 1980*1200 (highest 16/10 resolution) to build the standalone and:

  • check the screen ratio and choose the right one.

Right now my Gui are automatically repositioned and resized for the right ratio and the right resolution. But I still need to choose the starting resolution in the resolution dialog and go for full-screen.

I don’t want my client to be able to do that.

If someone can help… or tell me if it’s not possible.

up !

Is that it ?

But be wary that going for the highest resolution can eat a great amount of fps.