- Home /
Textures in GUI being scaled slightly?
Possibly this is a bug in Unity, but probably I'm just doing something wrong.
Whenever I add a texture in a GUI script, it's being scaled down slightly (1-2%), causing it to be blurry and a little smaller than it's meant to be. This is in Unity 3.5.2f2.
I'm not applying any scaling or using a camera at all. The texture is set to GUI mode and is actual size (no power-of-two scaling). Changes to the texture settings seem to have no effect on the problem. Using Point instead of Bilinear will just make it look messy instead of blurry.
This simple code will reproduce it:
public Texture2D myImage;
void OnGUI() {
GUI.Label(new Rect(0, 0, myImage.width, myImage.height), myImage);
}
I've confirmed that Unity is seeing and setting the width and height correctly in code. But if I have, say a 500x500 image, and I screenshot it being shown in Unity, it's actually showing as 493x493 and slightly blurred from being scaled.
Anyone else seen this, or know what I'm doing wrong?
Answer by Eric5h5 · Jul 20, 2012 at 04:45 AM
It's not a bug; labels have 4 pixel margins by default. You should use GUI.DrawTexture if you want to draw a texture as-is.
Your answer
Follow this Question
Related Questions
Aspect ratio keeping guitexture scaling 1 Answer
scaling a gui texture 2 Answers
How do you auto scale the space between Gui Buttons? 1 Answer
GUITexture Button? 1 Answer
rotating GUI texture by angle 2 Answers