private void OnDestroy() { if (this == instance) { instance = null; } // Re-initialize the tracker Init(); }
private static void Init() { // Check if the tracker has already been initialized if (instance != null && !instance.Equals(null)) { return; } // Don't initialize if the application is quitting if (quitting) { return; } var gameObject = new GameObject("Motive"); gameObject.hideFlags = HideFlags.HideAndDontSave; DontDestroyOnLoad(gameObject); instance = gameObject.AddComponent <Motive>(); }