Пример #1
0
    void Awake()
    {
        if (instance == null)
        {
            instance = this;
        }

        else if (instance != this)
        {
            Destroy(gameObject);
        }

        DontDestroyOnLoad(gameObject);
    }
Пример #2
0
    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);
    }
Пример #3
0
 void Awake()
 {
     _singleton = SingletonHeart.getInstance();
 }
Пример #4
0
 // Use this for initialization
 void Awake()
 {
     singletonStarInstance  = SingletonStar.getInstance();
     singletonHeartInstance = SingletonHeart.getInstance();
 }