2DTexture drawing not working although ratio is same

Hi,

I’ve been working on the HUD for my game, and I am trying to make a simple resources bar in the left-top. So i thought this would do the trick:

// Background
GUI.DrawTexture(new Rect(0, 0, 480, 45), resourcesBackgroundImage, ScaleMode.ScaleToFit, true, 0f);

The image is in fact 480x45, but yet it does not draw it in 480x45, as it leaves a small empty bar at the top and does not fill it.

When I use:

// Background
GUI.DrawTexture(new Rect(0, 0, 480, 45), resourcesBackgroundImage, ScaleMode.StretchToFill, true, 0f);

The image does get drawn in the 480x45, but it is no longer sharp. This occurs because it is transformed, but how can that be if the resolution is the same (480x45)?

Thanks in advance,
Z

PS: The image is in .png format

From my experience you get this line at the top if the texture’s wrapmode is set to “Repeat” in the import settings. Set it to “Clamp” and the line should be gone.

Thanks for the reply! The import settings were indeed the problem, it should have been set to GUI/Clamp instead of Repeat, as Unity automatically converted it to a POT-image, while it was supposed to be a NPOT-image.