//Singleton Pattern
 private void Awake()
 {
     if (Instance != null)
     {
         Destroy(gameObject);
         return;
     }
     Instance = this;
     DontDestroyOnLoad(gameObject);
 }
 // Use this for initialization
 void Start()
 {
     if (instance == null)
     {
         instance = this;
     }
     else
     {
         Destroy(gameObject);
     }
     DontDestroyOnLoad(gameObject);
 }
Exemple #3
0
 void Awake()
 {
     if (instance != null)
     {
         Destroy(gameObject);
     }
     else
     {
         instance = this;
         DontDestroyOnLoad(transform.gameObject);
     }
 }
Exemple #4
0
 public void Awake()
 {
     if (Instance == null)
     {
         Instance = this;
         DontDestroyOnLoad(gameObject);
     }
     else
     {
         Destroy(gameObject);
     }
 }
 void Awake()
 {
     if (instance != null && instance != this)
     {
         Destroy(this.gameObject);
         return;
     }
     else
     {
         instance = this;
     }
     DontDestroyOnLoad(this.gameObject);
 }
Exemple #6
0
 void Start()
 {
     if (Instance != null)
     {
         GameObject.Destroy(this.gameObject);
         return;
     }
     Instance = this;
     if (DontDestoryOnLoad)
     {
         GameObject.DontDestroyOnLoad(this);
     }
 }