When to use a canvas for background image?

Hello,
It seems the canvas is used here for a background image for the first time in this course. May I ask what are the pros and cons of this approach and maybe a rule of thumb when to use a canvas to display a background image and when to directly place a background image in front of the camera ?
Thanks and all the best,
Ido

1 Like

I noticed this as well. I would like some clarification on this.

Well… It is up to the situation and preference, if you are using it within the canvas, you will have the ability to use the rect transform and canvas mode to stretch it different ways accordingly to the player screen and accordingly to the situation, although if you move the camera around (like in a plataformer for example), the background will keep the same way and wont follow the camera, so you won’t be able to create parallax effects and won’t be able to create more complex or even 3d backgrounds (at least won’t be able to do it easily).

In the other hand the background in the world is less stretchable accordingly to the player screen, but it will function as an part of the world, so as you move the camera, it will progress accordingly.

Imo, if the background and camera won’t change during gameplay, there is no reason not to put it within a canvas that would make it easier to stretch it. But if the background is actually a part of the world and changes accordingly to the camera, or if it is more complex and need to have 3d elements and light effects, is more likely to be better to put it in the actual world space. In other words, If it needs to fit the screen, then make sense to put it in the canvas, if it is more important as part of the actual game world and environment, makes more sense to put it behind the camera.

1 Like

Privacy & Terms