Precise vertical alignment of GUI label

Hey all,

Forgive my ignorance if this is covered somewhere that I have missed, but I just can’t seem to get my GUI image to align correctly with the bottom of the application window. Here is the code I’m using:

GUI.Label(Rect (0, 768 - image.height, image.width, image.height), image);

The image is 61 px. wide x 64 px. tall.

When running at 1024 x 768, the left side of the image aligns properly with the left side of the application window, but there is a small gap between the button and the bottom of the window. (see photo).

Thanks for any help.

Matt

86530--3367--$guigap_131.jpg

Check the padding settings and make sure they are 0 (make a custom GUIStyle if necessary). Also you probably don’t want to hard-code GUIs to particular resolutions.

var myStyle : GUIStyle; // Use 0,0,0,0 for padding
var image : Texture2D;

function OnGUI () {
   GUI.Label(Rect (0, Screen.height - image.height, image.width, image.height), image, myStyle);
}

–Eric

Padding was the problem… thanks for the heads up. The hardcoded resolution value was just a leftover from my troubleshooting, [removing now] :slight_smile:

Thanks for the help.

MJ