To use states to manage object behavior, follow these steps:
- Create two UI Buttons at the top-middle of the screen. Name one Button-win and edit its text to read Win Game. Name the second Button-lose and edit its text to read Lose Game.
- Create a UI Text object at the top left of the screen. Name this Text-state-messages, and set its Rect Transform height property to 300 and its Text (Script) Paragraph Vertical Overflow property to Overflow.
- Create a new C# script class, GameStates.cs:
public class GameStates { public enum GameStateType { GamePlaying, GameWon, GameLost, } }
- Create the MyGameManager.cs C# script class, and add an instance object as a component to the Main Camera:
using UnityEngine; using ...