コード例 #1
0
 void Awake()
 {
     if (instance != null) {
         Debug.Log ("Wrong");
         //Destroy (gameObject);
         return;
     }
     instance = this;
 }
コード例 #2
0
 public static DontGetDestroyedOverlay GetInstance()
 {
     if (instance == null) {
         GameObject go = new GameObject("Whatever");
         go.AddComponent<DontGetDestroyedOverlay>();
         instance = go.GetComponent<DontGetDestroyedOverlay>();
     }
     return instance;
 }