Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private static INSTANCE_CLASS m_Instance;
- /// <summary>
- /// This callback is called after all Awake functions have been called by Unity.
- /// This makes sure that everything is initialized (a big issue in the editor)
- /// before creating an instance.
- /// </summary>
- [RuntimeInitializeOnLoadMethod]
- private static void CreateObject() {
- if (m_Instance == null) {
- var go = new GameObject("NAME OF OBJECT");
- m_Instance = go.AddComponent<INSTANCE_CLASS>();
- go.hideFlags = HideFlags.HideInHierarchy | HideFlags.HideInInspector;
- DontDestroyOnLoad(go);
- m_Instance.Initialize();
- }
- }
- private void Initialize() {
- }
Advertisement
Add Comment
Please, Sign In to add comment