We have decided that the UI in our game will be made up of three simple views:
We have created most of the MenuView. I am using two terms here, View and Canvas. In our simple game, both of them will mean the same thing. MenuCanvas is just the visible part of MenuView. Keep that in mind.
The simplest way to toggle the view's visibility is by enabling and disabling the Canvas component. Let's test how it works without the code for now:
It's been a while since we wrote some code. Let's implement the same behavior in the code. Add a Canvas
type public member to the GameManager
class and call it menuCanvas
. We will use this reference in GameManager
for easy access:
public Canvas menuCanvas;
Edit SetGameState
by adding three lines that enable and disable the Canvas component, as follows:
Well done! We have a piece of basic code that is enabling and disabling the Canvas for us.