Book Image

Learning NGUI for Unity

By : Charles Bernardoff (EURO)
Book Image

Learning NGUI for Unity

By: Charles Bernardoff (EURO)

Overview of this book

Table of Contents (17 chapters)
Learning NGUI for Unity
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Launch from the main menu


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:

  1. Select our UI Root GameObject. For its attached Menu 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...