Game Development Reference
In-Depth Information
Figure 3-8.
Importing NotificationsManager.cs into the Unity project. Remember: get into the habit of using meaningful folder
names, to bring organization to your assets
As mentioned in earlier sections, the NotificationsManager should be a
Singleton object
, meaning
there should be only one instance of it in memory at any one time. That instance should last
throughout the duration of the scene and beyond, if there are multiple scenes. The details of
creating and accessing Singleton objects globally are considered in depth in the next chapter.
Here we'll simply use a more informal, make-shift Singleton object. Just drag and drop the
NotificationsManager onto the
Camera
object in the scene (or onto an empty game object) to
instantiate the class as a
Component
. Since
we know
that NotificationsManager should be a
Singleton, then we'll simply
remember
that our scene already has an instance of this class and that
we need to create no more instances (see Figure
3-9
).