Auto scaling GUI

Hello everyone.

I’ve been looking for a solution to my problem for a while now and I didn’t find anything that works.

Here is my problem:

I’m creating a web build of my project.

My website, which displays the unity web player, is auto scaling the player’s size according to the user’s resolution.

Is there a way to code an automatic resize of the GUI?

Thanks.

Use GUIUtility.ScaleAroundPivot to adjust the size of your GUI to your liking. Beware of resolutions with different aspect ratio.

If you want to keep the pixel sizes of your element and just shift them around, detailed adjustment via scripting can’t be avoided (although you could still use ScaleAroundPivot by keeping the scale and moving the Pivot around, for example to keep buttons aligned to the right border or something, but the exact values that are required are somewhat difficult to figure out).

you should use a matrix(im not sure this works in web player) it will scale and position the GUI according to the aspect ratio and resolution. Ill try to find a link to them

Heres the link:
http://answers.unity3d.com/questions/142829/GUI-Placement-Question.html

You sure can do this… for example, here’s how I told my vignette (GUITexture) to be full screen size, no matter what resolution. Of course you can mess with the numbers. So you could make your buttons always be 1/8th of the screen width etc…

Vignette.guiTexture.pixelInset = Rect(-(Screen.width / 2), -(Screen.height / 2), Screen.width, Screen.height); 

The first two values are the pixel inset, the third and fourth are the size of the GUITexture. So you of course want to set the pixel inset to half of the size if you want to align it to the middle. Hope I’m being clear… still a bit of a noob myself. LOL.

EDIT: I should add, the pixel inset is measured from the bottom left corner.