- Home /
Question by
apoozery · Jul 28, 2018 at 09:49 AM ·
spawnclonepause menupause gamestopcoroutine
When I pause the game the clone does not stop
please I need help, I am beginner in coding. when I pause the game the clone still working so I don't know how to fix it.
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
public class GameplayController : MonoBehaviour {
public static GameplayController instance;
[SerializeField]
private Text gameoverScoreText;
[SerializeField]
private GameObject gameoverPanel;
[SerializeField]
private GameObject ready;
public GameObject pausePanel;
public void Awake () {
MakeInstance ();
}
public void MakeInstance (){
if (instance == null) {
instance = this;
}
}
// Use this for initialization
void Start () {
Time.timeScale = 0f;
}
// Update is called once per frame
void Update () {
}
public void GameoverShowPanel (int finalScore) {
gameoverPanel.SetActive (true);
gameoverScoreText.text = finalScore.ToString ();
StartCoroutine(RestartGame());
}
IEnumerator RestartGame() {
yield return new WaitForSecondsRealtime (3f);
SceneManager.LoadScene ("MainMenu");
}
public void StartTheGame (){
Time.timeScale = 1f;
ready.SetActive (false);
}
public void PauseTheGame () {
Time.timeScale = 0f;
pausePanel.SetActive (true);
}
public void ResumeTheGame (){
Time.timeScale = 1f;
pausePanel.SetActive (false);
}
public void BackToMainMenu () {
Time.timeScale = 1f;
SceneManager.LoadScene ("MainMenu");
}
}
Comment
Your answer
Follow this Question
Related Questions
Make button be above another button? 1 Answer
I dont want "(clone)" but how to change? 2 Answers
Escape key not working 1 Answer
Fruit ninja course 1 Answer
How to make the clones of a zombie continue to clone? 2 Answers