Time for action – setting up nine States and three Scenes
We're going to modify some States and create some new ones. We're also going to use three Scenes.
In Unity
- Create three Scenes:
Scene0
,Scene1
, andScene2.
- In the menu, open File | Build Settings....
- Add the three Scenes to Scenes in Build.
- Temporarily add some GameObjects to Scene1 and Scene2 for testing.
- Open Scene1 and add a Cube GameObject.
- Open Scene2 and add two Sphere GameObjects.
- Reload Scene0
- Double-click on BeginState to edit
In MonoDevelop
- Edit the
BeginState
constructor method as follows to add anif
statement for loadingScene0
:public BeginState (StateManager managerRef) { manager = managerRef; if(Application.loadedLevelName != "Scene0") Application.LoadLevel("Scene0"); }
- Make new C# classes ...
Get Learning C# by Developing Games with Unity 3D Beginner's Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.