- Home /
Raw Image vs Image?
I can't understant why Raw Image component exists. In the manual it claims
" you can use it to display any texture available to the Unity player. For example, you might show an image downloaded from a URL using the WWW class or a texture from an object in a game"
However you can create a Sprite from texture with no problem using Sprite.Create(texture);
So the entire of purpose of Raw Image escapes me.
Just wondering if anyone knows of a performance reason or anything of the like?
Answer by steakpinball · Sep 22, 2015 at 01:38 PM
Image
is for displaying Sprites only. RawImage
is for displaying any type of texture.
Sprites are easier to work with, but Sprite.Create
is an expensive operation. It takes a comparatively long time and uses a lot of memory. It should be used sparingly. By using a RawImage
you can skip the step of creating a sprite. If displaying something like a RenderTexture
using an Image you would need to call Sprite.Create every frame. That would be quite taxing.
Bottom Line: Use RawImage
when you already have a plain texture, because converting it to a sprite would be slower and use more memory.
Thanks for your answer @brianturner, but, can you elaborate a little bit more on when to use what? When to use sprites (Image)? When to use plain texture (Raw Image)?
The only case in which I'm thinking Sprites are a good choice, should be in elements that uses fillAmount (like progress bars or stuff like that). Thanks again!
Form the Documentation for RawImage
$$anonymous$$eep in $$anonymous$$d that this will create an extra draw call with each RawImage present, so it's best to use it only for backgrounds or temporary visible graphics.
That means the per-frame performance is slower though it seems.
What about if you were loading a large user-provided image (e.g. a high res backdrop) and planned to have it persist for the rest of the user's session? Would it make sense to convert to a Sprite then? How would you go from raw image bytes (e.g. a jpg file) to a Sprite that is ready to go?
Your answer
Follow this Question
Related Questions
How to get the fingerID (Touch) that is pressing a specific UI button. 0 Answers
Raycast against UI in world space 4 Answers
How do I mask out part of canvas panel?,How can I mask out part of a canvas panel? 4 Answers
Levels changing with UI best practice 2 Answers
button to select what player shoots 0 Answers