void Update() { if (resume != null && quit != null && menu != null) { RaycastHit seen; Ray raydirection = new Ray(transform.position, transform.forward); if (Physics.Raycast(raydirection, out seen, sightlength)) { if (seen.collider.tag.Equals("ResumeGame")) { if (resume.load()) { pgc.resume(); } } else if (seen.collider.tag.Equals("QuitGame")) { if (quit.load()) { Application.Quit(); } } else if (seen.collider.transform.name.Equals("MenuGame")) { if (menu.load()) { pgc.inactivatePauseMenu(); Time.timeScale = 1; gameManager.resetGame(); SceneManager.LoadScene("GameStart"); } } else { resume.unload(); quit.unload(); menu.unload(); } } else { resume.unload(); quit.unload(); menu.unload(); } } else { resume = FindObjectOfType <ResumeGame>(); quit = FindObjectOfType <QuitGame>(); menu = FindObjectOfType <MenuGame>(); } }
void Update() { RaycastHit seen; Ray raydirection = new Ray(transform.position, transform.forward); if (Physics.Raycast(raydirection, out seen, sightlength)) { if (seen.collider.transform.name.Equals("MenuGame")) { survival.unload(); if (back.load()) { gameManager.resetGame(); SceneManager.LoadScene("GameStart"); } } else if (seen.collider.transform.name.Equals("QuitGame")) { back.unload(); if (survival.load()) { Application.Quit(); } } else { unloadEverything(); } } else { unloadEverything(); } }