I successfully wrote a script that pauses the game by essentially setting the Time.timeScale to 0. However, with this script, I also enable a pause menu UI. I want to animate the UI to move slightly to the right when I hover, but since the Time.timeScale is 0, is this even possible to do while paused?
Script below:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Pause : MonoBehaviour {
bool pauseState = false;
public GameObject pauseMenu;
void Update()
{
if (pauseMenu.activeSelf)
{
pauseState = true;
//Debug.Log("UpdateActive");
}
else
{
pauseState = false;
//Debug.Log("UpdateFalse");
}
if (Input.GetKeyDown("escape") && pauseState == false)
{
Time.timeScale = 0;
pauseMenu.SetActive(true);
//Debug.Log("pauseState = true");
}
else if (Input.GetKeyDown("escape") && pauseState == true)
{
Time.timeScale = 1;
pauseMenu.SetActive(false);
//Debug.Log("pauseState = false");
}
}
public void ResumeGame()
{
Time.timeScale = 1;
pauseMenu.SetActive(false);
//Debug.Log("pauseState = false");
}
public void QuitGame()
{
Application.Quit();
Debug.Log("Game Quit Successful!");
}
}
Note: Wasn’t sure if Scripting or UI was the best place to post this, but since this involves a pause script I thought this forum would be the safer option.