Creating Game Manager using Singleton pattern and MonoBehaviour in Unity3d

wp-content/uploads/2013/02/unity_sm-300x240.png

Here is another simple example of how you  game manager could be implemented with use of DontDestroyOnLoad()  and additional isActive()  method if it derives from MonoBehaviour.

I previous post we it was  explained how we can implement singleton pattern and persist its instance after reloading the scene. Now lets have a look at how we could take advantage of extending MonoBehaviour class and using DontDestroyOnLoad()  method.

Example shown in previous post provides easy access to all public properties and methods of GameManager singleton retrieved via GameManager.instance  property. This example however takes it to the next level, as you can now add public properties which you can modify directly from within Unity3d Editor.

Series Navigation<< Creating Game Manager using State Machine and Singleton pattern in Unity3d – UPDATE: thrown error explained
This entry is part 3 of 3 in the series Creating Game Manager in Unity3d

Freelance developer, IT enthusiast, blogger with entrepreneurial spirit and passion for making games

Tagged with:
, , ,
Posted in
Games Development, Technical
Categories