- Home /
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!!
Answer by Graham-Dunnett · Jul 02, 2011 at 08:27 PM
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.
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?
Answer by Grady · Jul 02, 2011 at 02:03 PM
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
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