/// <summary> /// Runs on controller creation. /// </summary> private void Awake() { // If the object has not been set yet (this object) if (canvas == null) { // Don't EVER destroy this one, and set this object so we have a reference to it later. DontDestroyOnLoad(gameObject); canvas = this; // Reassign the button onClick methods Button[] buttons = this.gameObject.GetComponentsInChildren <Button>(); foreach (Button b in buttons) { if (b.name == "ButtonMainMenu") { b.onClick.AddListener(LocalNavigation_Title); } if (b.name == "ButtonQuit") { b.onClick.AddListener(LocalNavigation_Quit); } } } else if (canvas != this) { // If there is an object already stored, and it's not this one, destroy this! Destroy(gameObject); } }
// Start is called before the first frame update void Start() { _gameManager = GameObject.Find("GameManager").GetComponent <GameManager>(); _musicManager = GameObject.Find("MusicManager").GetComponent <MusicManager>(); _mainGameStateManager = GameObject.Find("MainGameStateManager").GetComponent <MainGameStateManager>(); _mainSceneButtons = GameObject.Find("MainSceneButtons").GetComponent <MainSceneButtons>(); _spawnManager = GameObject.Find("SpawnManager").GetComponent <SpawnManager>(); _player = GameObject.Find("Player").GetComponent <Player>(); _canvasMain = gameObjectCanvasMain.GetComponent <CanvasMain>(); _canvasGameOver = gameObjectCanvasGameOver.GetComponent <CanvasGameOver>(); _canvasRecords = gameObjectCanvasRecords.GetComponent <CanvasRecords>(); _audioSource = GetComponent <AudioSource>(); StartCoroutine(CoroutineIntroduction()); }
private void Start() { Instance = this; }