void Update() { secondTimer += Time.deltaTime; if (secondTimer > 1) { secondTimer = 0; timerSound.Play(); } TimeLeft -= Time.deltaTime; float tempTime = TimeLeft; int minutes = (int)tempTime / 60; int seconds = (int)tempTime % 60; timer.text = minutes.ToString() + ":" + seconds.ToString(); if (TimeLeft < 0) { gameOver.EndGame(); GameObject.Destroy(gameObject); } }
void OnDestroy() { gameOver.EndGame(); }