
Learning C# by Developing Games with Unity 3D Beginner's Guide
By :

In the code block of the Awake()
method, we're going to check if the GameManager GameObject already exists. If it doesn't, we'll save it to a variable and tell Unity not to destroy it when any other Scene level is loaded. If it does already exist, we'll tell Unity to destroy any new GameManager GameObjects created.
Insert the new code as shown in the following steps:
Add a new static
variable on line 9.
Add the Awake()
method at lines 11 through 22 as shown in the following screenshot:
An analysis of the code shown in the preceding screenshot is as follows:On the StateManager
class
Line 9: private static StateManager instanceRef;
This variable named instanceRef
stores a StateManager
type which is a reference to the StateManager
object in the memory
This is also a static
variable
This means, that in this example, each instance of the StateManager
Component object that's created will share and see the same value
It is...
Change the font size
Change margin width
Change background colour