- Home /
GUI object misalignment, Why is this happening?
So I've just started working with the 2D part of unity and I'm trying to get a gui object to fit in the bottom left corner of the screen but when it appears to fit in the editor and I build and run it to check it doesn't fit. I'm not sure why this is happening and I've been trying to figure it out on my own for a week now.
If anyone knows why this is happening and how to fix this it'd be wonderful if I could get some help on it.
Could you upload a pic of the gui element's inspector view?
Answer by NickP_2 · Apr 16, 2014 at 02:34 PM
GUITextures are tricky to place, they have 2 methods of positioning; transfer and pixelInset.
If you set all the values to 0 in pixelInset, you can control the GUITexute completely on screensize with the transform values, so it doesn't matter what size of screen or resolution, the GUITexture will always have the same size or position compared to the size/resolution. For example: when the texture is half the screen on 400*800, it will also be half of the screen on 1600*900.
If you work with pixelInset, the position is absolute in pixels, so when you enter position x = 400 and y = 0, it will change position in other screen sizes. same with size.
Maybe you got confused with these? I'm very bad at explaining so here's unity's explanation: **HERE**
Hope it helped
Answer by Owen-Reynolds · Apr 16, 2014 at 02:51 PM
That little thing is a GUITexture, the one currently with default name UnityWatermark-small?
Zero-out everything below pixelInset. Instead, adjust the Transform scale and position. Position is the center, and scale is % of the screen. For example scale=(1, 0.1) and position = (0.5, 0.05) will make a long bar over the bottom 10% of the screen. To put in a corner, position should be 1/2 of the scale.
The pixel stuff, IMHO, is for those very rare times when you can count pixels (like it will only ever run on a 1280x960 screen) and feel like you want to.
Your answer
Follow this Question
Related Questions
Play sound once on collision 1 Answer
Laser beam using particle system Unity2d. 0 Answers
Vector3.MoveTowards doesnt work 1 Answer
Does someone know how to simply invert mouse movement? 2 Answers
Instantiated object not showing in scene or hierarchy 2 Answers