0
,0
,0
.0
,1
,0
.DontDestroyOnLoad()
method called in StateManager
, any child objects of GameManager will also be allowed to exist in all ScenesWhen you click on Play and move from one Scene to another, you will see the Player appear in every Scene, along with the Directional Light.
The whole purpose of the State Machine is its simplicity of control. However, a game's code needs to access many types of data. For instance, we're going to show three splash screens. Do we really want to fill the State Machine itself with all kinds of variables storing image files and other game data? How about scoring data? Of course not, otherwise the script starts getting long and cumbersome to read.
Instead, let's create a separate Component script class whose sole purpose is to contain game data. This way we know exactly where to look for the data when we need it, and where to store it during the game. All we'll need to do is create a single variable in the StateManager
that points to (references) this special data script.
18.191.195.111