Now that our game is starting to work, we should make sure we can go from the Menu
scene to the Game
scene without any problem.
Open the Menu
scene now. We'll make sure the main menu's background texture fades out after the Game
scene is loaded, and the main menu's UI camera is disabled to ensure no elements are displayed during the game.
Open our MenuManager.cs
script and add the following global variable declarations:
// We'll need the UI camera public Camera uiCamera; // We'll need the UI background public GameObject background;
Save the script and go back to Unity. We'll assign these two new variables now:
Select our
UI Root
GameObject. For its attachedMenu Manager
:Drag
UI Root
|Camera
into its UI Camera field.Drag
UI Root
|Background
into the Background field.
Go back to the MenuManager.cs
script and add the following EnterGame()
coroutine:
// EnterGame Coroutine private IEnumerator EnterGameRoutine() { // Fade out the UI background TweenAlpha.Begin(background...