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 for the new States. The following State Machine files should be coded as shown in Appendix A:
The
BeginState
fileThe
SetupState
fileThe
PlayStateScene1_1
file: (1 of 2 available States in Scene1)The
PlayStateScene1_2
file: (2 of 2...