Пример #1
0
 /// <summary>
 /// Only ever called once, mainly used to initialize variables.
 /// </summary>
 private void Awake()
 {
     if (Instance != null)
     {
         Destroy(Instance.gameObject);
     }
     DontDestroyOnLoad(this);
     Instance = this;
 }
Пример #2
0
 /// <summary>
 /// Called when the script is being destroyed.
 /// </summary>
 private void OnDestroy()
 {
     Instance = null;
 }