public void RestartLevel() { int currentSceneIndex = SceneManager.GetActiveScene().buildIndex; ScoreKeep sk = FindObjectOfType <ScoreKeep>(); sk.SetPlayerHP(HpAtLevel); sk.SetScore(ScoreAtLevel); sk.SetMoney(MoneyAtLevel); sk.lastLvl = currentSceneIndex; Instantiate(Restarter); }
private void Update() { if (FindObjectsOfType <ScoreKeep>().Length > 0) { sk = FindObjectOfType <ScoreKeep>(); sk.SetMoney(Money); sk.SetScore(Score); sk.SetPlayerHP(playerHP); Destroy(this.gameObject); } if (FindObjectsOfType <FinalCanvas>().Length > 0) { FinalCanvas fc = FindObjectOfType <FinalCanvas>(); fc.Score.GetComponent <TextMeshProUGUI>().text = "" + Score; Destroy(this.gameObject); } }