コード例 #1
0
ファイル: SingletonStar.cs プロジェクト: djchaos/Portfolio
    public static SingletonStar getInstance()
    {
        if (_instance == null)
        {
            _instance = GameObject.FindObjectOfType <SingletonStar>();
        }

        /*
         *      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("SingletonStar");
            _instance = go.AddComponent <SingletonStar>();
        }


        return(_instance);
    }
コード例 #2
0
 // Use this for initialization
 void Awake()
 {
     singletonStarInstance  = SingletonStar.getInstance();
     singletonHeartInstance = SingletonHeart.getInstance();
 }
コード例 #3
0
ファイル: StarManager.cs プロジェクト: djchaos/Portfolio
 void Awake()
 {
     _singleton = SingletonStar.getInstance();
 }