- Home /
Sprite.Create looks compressed
I had been using GUI.DrawTexture for some images before and I'm currently trying to redesign with the new GUI... I need to create the sprite on the fly, not in the editor but they appear as if they've been imported compressed or possibly with mipmaps.
So I still download the png from my server and create Texture2D using
myTex.LoadImage(bytes);
Using this texture in GUI.DrawTexture behaves exactly as I expect it to.
Now I have a panel under my canvas with an Image component which I need to set in code
gameobject.GetComponent<Image>().sprite = Sprite.Create(myTex, new Rect(0, 0, myTex.width, myTex.height), new Vector2(0.5f,0.5f));
The image this way is very blurry as if it was imported compressed as I said above... Anyone know what I'm doing wrong here?
Answer by smoggach · Oct 08, 2014 at 04:20 PM
How are you creating your texture? This is where the error is. You need to set the proper TextureFormat when creating the texture. Chances are you are currently using default which is usually compressed. What you're looking for is TextureFormat.ARGB32
Thank you very much I had exactly the same problem and your answer helped me a lot.
Your answer
Follow this Question
Related Questions
Creating point cloud from 16 bit 1 channel png 0 Answers
Create, export, and then load a huge image. 2 Answers
Scaling / Resizing an Image (Texture2D) 6 Answers