Gui does not fill the screen?

Hello, I am trying to have an image fill the entire screen. I used this code,however, it will not fill the entire screen? Is there anything wrong with this?

void OnGUI()
{
    GUI.DrawTexture(new Rect(0, 0, Screen.width, Screen.height), backgroundImage, ScaleMode.ScaleToFit, true, 10.0F);
}

First of all you should use StretchToFill instead of ScaleToFit since ScaleToFit will only scale the texture so it fits within the screen.

You also shouldn’t pass an aspect ratio. It looks like you just copied the example from the docs. A ratio of 10 doesn’t make much sense.

Try this instead:

void OnGUI()
{
    GUI.DrawTexture(new Rect(0, 0, Screen.width, Screen.height), backgroundImage);
}

The default values are exactly what you need :wink: