Time for action – instantiating the BeginState class
We are going to instantiate the BeginState
class to create an instance object in the memory. This will demonstrate how objects are created. Before we can do this, we first need to attach the StateManager
script to a GameObject. To do so, perform the following steps:
- Attach the
StateManager
script to the Main Camera GameObject. - Click on Play to show the results in the Console as shown in the following screenshot:
What just happened?
The BeginState()
method in the BeginState
class is a special method known as a constructor. It serves the same purpose as the Start()
method or the Awake()
method in ...
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.