void OnDestroy() { if (_instance == this) { _instance = null; } }
void Awake() { if (_instance != null) { Debug.LogError("DailyBonusManager: detected singleton instance has existed. Destroy this one " + gameObject.name); Destroy(this); return; } _instance = this; }
// to be sure that not more that one instance of manager will be on scene void Awake() { if (_instance != null && _instance != this) { Destroy(gameObject); return; } _instance = this; DontDestroyOnLoad(gameObject); //PlayerPrefs.DeleteAll(); // Be Sure to not parse empty string if (PlayerPrefs.GetString("DateOfLastPlayed") == String.Empty) { Debug.Log("First Data Initialization"); PlayerPrefs.SetString("DateOfLastPlayed", DateTime.Now.ToString()); } }