Time for action – creating a script and a class
We are going to create the StateManager
script and the BeginState
class, then add some code so that we can instantiate BeginState
to make an instance of BeginState
. With the help of the next screenshot, perform the following steps:
In the Unity Project window, create a C# Script in the
Scripts
folder.Name the script
StateManager
.Double-click on
StateMana
ger
to open it in MonoDevelop.In the MonoDevelop Solution window, right-click on the
Code
folder and select Add | New Folder.Name the folder
States
.Right-click on the
States
folder and select Add | New File.In the New File window, select General | Empty Class.
In the Name field at the bottom, enter
BeginState
.Click on the New button to create the
class
file.
The following screenshot is the Solution window of MonoDevelop:
With the BeginState
class file open in MonoDevelop, make the changes as shown in the next screenshot:
Change line 1 to
using UnityEngine;
.Change line 3 to
namespace Assets.Code...