
Learning C# by Developing Games with Unity 3D Beginner's Guide
By :

We'll add a single line of code in BeginState
and in LostState
to change Scenes.
In BeginState
, add Application.LoadLevel("Scene1");
into the Switch()
method on line 42 as shown in the following screenshot:
In LostState
, add Application.LoadLevel("BeginningScene");
into the StateUpdate()
method on line 20 as shown in the following screenshot:
If earlier in this chapter you changed WonState
to switch to PlayState
instead of starting over with BeginState
, we're ready to test our State Machine again. If you didn't, the following are the changes you need to make to WonState
:
Save all your changes.
Have BeginningScene loaded and showing in Unity.
Click on Play.
You should now be changing Scenes as you go from BeginState
to PlayState
. To get back to BeginState
, you have to first switch to LostState
.
Q1. The State classes implement the IStateBase
interface guaranteeing certain methods...
Change the font size
Change margin width
Change background colour