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?

1 Like

1 Answer

1

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!

Excellent, I love bottom lanes

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?

Well, I love the way you make the answer, It's actually prove that you're an professional

Corrected with your suggestion