Time for action – adding OnGUI to StateManager

Add the OnGUI() method to StateManager as shown in the following screenshot. Begin the method on line 22:

Time for action – adding OnGUI to StateManager

What just happened?

Unity calls the OnGUI() method at least once per frame, but it could also be several times per frame. This means that the ShowIt() method on the active State will be also called for displaying graphics, text, and buttons.

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.