x


How can I prevent my GUI background texture from getting pixelated or stretched?

Hello,

I have a high res image that I would like to use for my background of my GUI menu (1600 x 1200), but I cant seem to get it right. Its either stretched or pixilated.

I'm currently using this to display my image:

GUI.DrawTexture(Rect(0, 0, Screen.width, Screen.height), 
                MenuBackground, ScaleMode.StretchToFill, 
                true, 10.0f);

I have also made the image true colour and given it a size of 4096.

With that current code - it looks pixilated. (I would like to keeps its ratio too)

Please help ... Thanks, Ollie

more ▼

asked Dec 16 '10 at 08:19 PM

oliver-jones gravatar image

oliver-jones
2.5k 205 225 254

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

make an empty GUITexture Object and drag your texture onto it

edit: you don't need to script it if you use a GUITexture gameobject, but if you don't, use ScaleAndrop instead of StretchToFill

more ▼

answered Dec 16 '10 at 08:25 PM

Bravini gravatar image

Bravini
1.1k 6 11 29

How do I make that dynamic to the screen size and yet maintain ratio?

Dec 16 '10 at 08:34 PM oliver-jones

you can use a script that acess this guitexture attributes like any gameobject, I do this mostly for title screens.

Dec 17 '10 at 12:07 PM Bravini

Right? Thats what I've done (read my post). But it doesn't display it properly - its either stretched or out of ratio

Dec 20 '10 at 01:19 PM oliver-jones

you got me wrong, you're using a gui.drawtexture, i mean for you to use a guitexture gameobject. Also, if you use StretchToFill, it gonna stretch and get pixelated, try ScaleAndCrop

Dec 20 '10 at 07:27 PM Bravini
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x3688
x2199
x258
x166
x7

asked: Dec 16 '10 at 08:19 PM

Seen: 2181 times

Last Updated: Dec 17 '10 at 02:22 AM