Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

How do i put a timer after a pause menu

Discussion in 'Getting Started' started by Minesam, May 3, 2019.

  1. Minesam

    Minesam

    Joined:
    Apr 25, 2019
    Posts:
    1
    Hello! Ive been traying to add a timer animation after a pause, i already have the animation of the timer but i dont really know how to make it pop up after the pause menu is closed plus ill like the game to be stoped while the animation is running and once the animations is over the game resumes.
    Ill add the PauseMenu script.
    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine.SceneManagement;
    using UnityEngine;

    public class PauseMenu : MonoBehaviour
    {
    public static bool GameIsPaused = false;

    public GameObject pauseMenuUI;




    void Start()
    {
    GameIsPaused = false;
    }

    void Update ()
    {
    if(Input.GetKeyDown(KeyCode.Escape))
    {
    Cursor.lockState = CursorLockMode.None;
    Cursor.visible = true;
    if (GameIsPaused)
    {
    Resume();
    }
    else
    {
    Pause();
    }
    }
    }

    public void Resume ()
    {
    pauseMenuUI.SetActive(false);
    Time.timeScale = 1f;
    GameIsPaused = false;
    }

    void Pause()
    {
    pauseMenuUI.SetActive(true);
    Time.timeScale = 0f;
    GameIsPaused = true;
    }

    public void LoadOptionsMenu()
    {
    Time.timeScale = 0f;
    SceneManager.LoadScene(0);
    }

    public void QuitGame()
    {
    Application.Quit();
    Debug.Log("Quitting");
    }

    public void QuitToMainMenu()
    {
    Time.timeScale = 1f;
    SceneManager.LoadScene(0);
    }

    public void TogglePause()
    {
    GameIsPaused = !GameIsPaused;
    pauseMenuUI.SetActive(GameIsPaused);
    Time.timeScale =GameIsPaused ? 0 : 1;
    }


    }
     

    Attached Files:

    Last edited: May 3, 2019