Time for action – adding GameObjects and a button to the Scene
Add a Plane GameObject and a Cube GameObject to the Scene panel. Add a Rigidbody Component to the Cube GameObject so it will fall to the Plane GameObject. Also add a Directional Light to the Scene panel if there isn't one already. Then we'll add a GUI button to switch to the PlayState
object. To do so, perform the following steps:
In the menu, navigate to GameObject | Create Other | Plane.
In the Inspector panel, make sure the Position is 0,0,0 for X,Y and Z.
In the menu, navigate to GameObject | Create Other | Cube.
Set the values in the Inspector panel as shown in the next screenshot.
Select Cube in the Hierarchy panel.
In the menu, navigate to Component | Physics | Rigidbody.
In the menu, navigate to GameObject | Create Other | Directional Light if needed.
Add the following code to the code block of the
ShowIt()
method ofBeginState
: