void Awake() { if (instance == null) { instance = this; } else if (instance != this) { Destroy(gameObject); } DontDestroyOnLoad(gameObject); }
public static SingletonHeart getInstance() { if (_instance == null) { _instance = GameObject.FindObjectOfType <SingletonHeart>(); } /* * if(_instance == null) * { * Debug.LogError("An instance of Singleton is needed in the scene, but there's none."); * } */ if (_instance == null) { GameObject go = new GameObject("SingletonHeart"); _instance = go.AddComponent <SingletonHeart>(); } return(_instance); }
void Awake() { _singleton = SingletonHeart.getInstance(); }
// Use this for initialization void Awake() { singletonStarInstance = SingletonStar.getInstance(); singletonHeartInstance = SingletonHeart.getInstance(); }