x


Keeping a GUI texture from moving during change of screen size

While setting up my own party creation scene in unity I noticed that some of my GUIs would move out of place if I changed to aspect ratio of the screen. How do I keep this from happening, I know it has to do with Screen.width, and Height, but even if I use those, and try to altr postions from them, it still does not work.... thanks in advance :) everyone that has helped me this far is awesom!!

more ▼

asked Jul 02 '11 at 05:34 AM

Spittin_fire gravatar image

Spittin_fire
16 6 7 9

(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

http://unity3d.com/support/documentation/Components/class-GuiTexture.html

Pixel Inset

The purpose of the Pixel Inset is to prevent textures from scaling with screen resolution, and keeping thim in a fixed pixel size. This allows you to render a texture without any scaling. This means that players who run your game in higher resolutions will see your textures in smaller areas of the screen, allowing them to have more screen real-estate for your gameplay graphics.

To use it effectively, you need to set the scale of the GUI Texture's Transform to (0, 0, 0). Now, the Pixel Inset is in full control of the texture's size and you can set the Pixel Inset values to be the exact pixel size of your Texture.

more ▼

answered Jul 02 '11 at 08:27 PM

Graham Dunnett gravatar image

Graham Dunnett ♦♦
11.7k 11 20 64

The pixel inset is not giving me what I was wanting, I know you said, but I didnt realize. I still want my guis to be stretched to make up for higher aspect ration, just... dont move, is there a way to do this?

Jul 05 '11 at 05:40 PM Spittin_fire
(comments are locked)
10|3000 characters needed characters left

This happens to me all the time... I'm not sure that there is much you can do about it, all I do is make the editor screen as big as possible, and then put my GUI elements in when the screen is at the size that it would be if the game was built.

Also, feel free to build your game and see where it is in relation to where you put it in the editor....

Hope this helps

-Grady

more ▼

answered Jul 02 '11 at 02:03 PM

Grady gravatar image

Grady
1.1k 66 70 82

I am going to have a lot of 'GUI "Layer"' so I'm thinking, if I got the background image in a menu, simply set with drawtexture, but I glue the above icons in place, then when the resolution is changed the big texture will scale, thus causing all of the smaller icons to appear out of place?! hmm, lemme go play around with this and see if I can make my gui graphics exact.. Thanks so much for this advice sir Graham... ;D

Jul 03 '11 at 10:57 PM Spittin_fire
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x3680
x2196
x484

asked: Jul 02 '11 at 05:34 AM

Seen: 1722 times

Last Updated: Jul 06 '11 at 10:36 AM