Creating a singleton game manager

Hey guys,

Whats a good way to create a singleton game manager that can be accessed everywhere as a global class with static variables that will spit the same constant values to every class that pulls those values? And what would be the way to implement it in Unity? Do I have to attach it to a GameObject? Can it just be there in a folder without being in the scene visually?

Thanks in advance.

Put it in a public class, make all the variables public static, and put the script into a Plugins folder. If you want to implement Start and Update it needs to derive from MonoBehaviour and I think needs to be attached to an object. Some folks like to have an Instance public static and then instantiate one of these at start, then you can access the instance from the public static var (see Qualcomm AR CameraDevice). You can ‘drive’ these vars from other scripts though, so it doesn’t really need to be MonoBehaviour, but if you want it all self-contained as much as possible, do that.