Why use multiple Scenes instead of multiple Canvas objects?

In Quiz Master we only used a single Scene, which in the lecture we reload to start over. In some other projects we use multiple Scenes and load each one when we need to change the content of the screen.

However, in Quiz Master we saw that you can disable a Canvas and enable another Canvas to get a similar type of effect to loading a new Scene.

Other than having a lot of info in a single Scene where you might have multiple Canvas objects with various children for each Canvas, what is the advantage of using Scenes?

Does it save memory?

Is one way faster than the other in changing what is on the screen?

I am curious to know which is best to use. I am sure there are tradeoffs to both methods.

Hi,

Those are very good questions.

When starting a new scene, all non-persistent game objects get destroyed. In some games, that’s exactly what we want. It is also an easy way to restart a level with all enemies in it that the player killed before he died.

In little games like ours, it does not make much sense to develop a complex solution for reusing all these things because the impact on the performance would be unnoticeable. Time is crucial because if we work on our game too long, it might be that the technology will be outdated once we completed the project. We don’t want to waste our time with micro-optimisation nobody will ever notice. Our little game is “nothing” for our modern, powerful devices.

The Quiz Master game has got a few elements, and that’s it. If we reloaded the level, we would have make some elements persistent, for example, the score. This probably requires as much code as simply resetting a few variables. Both approaches are equally valid.

As usual, almost everything depends on the context.


See also:

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.

Privacy & Terms