When the Level Up screen is displayed, pressing the Esc button causes the game to pause, so I modified the code. What I want is for the Paused screen to be able to activate or deactivate even when the Level Up screen is active, but despite modifying the code, the Paused screen does not activate when the Level Up screen is displayed. How can I resolve this issue? I need your help, Mr.
GameManager.cs
public void PauseGame()
{
if (currentState != GameState.Paused)
{
previousState = currentState;
ChangeState(GameState.Paused);
Time.timeScale = 0f;
pauseScreen.SetActive(true);
}
}
public void ResumeGame()
{
if (currentState == GameState.Paused)
{
if (currentState == GameState.Paused)
{
ChangeState(previousState);
Time.timeScale = (currentState == GameState.LevelUp) ? 0f : 1f;
pauseScreen.SetActive(false);
}
}
}
void CheckForPauseAndResume()
{
if (Input.GetKeyUp(KeyCode.Escape))
{
if (currentState == GameState.Paused)
{
ResumeGame();
}
else
{
if (currentState == GameState.LevelUp)
{
pauseScreen.SetActive(true);
}
else
{
PauseGame();
}
}
}
}