コード例 #1
0
 protected virtual void OnDestroy()
 {
     if (_instance == this)
     {
         _instance = null;
     }
 }
コード例 #2
0
 protected virtual void Awake()
 {
     if (_instance != null)
     {
         Debug.Log(string.Format("Multiple instances of script {0}!", GetType()), gameObject);
         Debug.Log("Other instance: " + _instance, _instance);
     }
     else
     {
         _instance = this;
     }
 }