void Awake() { if (instance == null) { instance = this; } else if (instance != this) { Destroy(gameObject); } DontDestroyOnLoad(gameObject); enemies = new List <Enemy>(); boardScript = GetComponent <BoardManager>(); boardScript1 = GetComponent <BoardManager1>(); boardScript2 = GetComponent <BoardManager2>(); boardScript3 = GetComponent <BoardManager3>(); InitGame(); }
// Awake é uma função da Unity que é executada antes do Start. private void Awake() { // Checa se instance e está vazia, e se estiver atribui a ela a própria instância do GameManager. if (instance == null) { instance = this; } else if (instance != this) { Destroy(gameObject); } // Não destrói o game object ao carregar uma cena. DontDestroyOnLoad(gameObject); // Inicializa nossa lista de inimigos (fazer depois da animação do inimigo). enemies = new List <Enemy2>(); // Referência ao componente Board Manager. boardScript = GetComponent <BoardManager2>(); InitGame(); }