Many NGUI components broadcast events, for which you can set an event delegate—also known as a callback method—executed when the event is triggered. We did it through the Inspector view by assigning the Notify and Method fields when buttons were clicked.
For any type of tween, you can set a specific event delegate for when the tween is finished. We'll see how to do this through code. Before we continue, we must create our callback first. Let's create a callback that loads a new scene.
Open our MenuManager.cs
script, and add this static LoadGameScene()
callback method:
public static void LoadGameScene()
{
//Load the Game scene now
Application.LoadLevel("Game");
}
Save the script. The preceding code requests to load the Game
scene. To ensure Unity finds our scenes at runtime, we'll need to create the Game
scene and add both Menu
and Game
scenes to the build settings:
Navigate to File | Build Settings.
Click on the Add Current button (don't close the window now).
In Unity...