GUI background texture to fill the screen

Hi, Ive created a menu GUI for my game.

Currently I have two buttons and a background image.

My code for the background

//BG Images
GUI.Box( Rect(0, 0, Screen.width, Screen.height), " ");
GUI.Label( Rect(0, 0, Screen.width, Screen.height), mainMenuBG);

I used Screen.width and Screen.height to fill the screen with my texture, however It is only filling half the screen

Could someone please tell me what I doing wrong.

Thanks.

El3et, i was having problems with GUI too, i switched to work with guiTextures that works with transforms…

if you want to create a bg and this fills any aspect ratio, just create a guiTexture, set all pixel inset to 0 , width and height to 0 too, and set scale X and Y to 1, and there you go.

buttons can be created with gui as you desired…

El3et, instead of GUI.Label, use GUI.DrawTexture.

Label has a lot of parameters, being an element of GUISkin, like margins, paddings, alignment, etc, and some of them could be causing this unnatural behaviour.

When you simply want to display an image, use DrawTexture instead,

Also, I uploaded a few months ago on the wiki a short code that allows you to replace Rect with scaledRect, that auto-formats your dimensions to be resolution independent without messing with Screen.width / height.

Check it out here :