::Okay, new idea. I don’t think your button can set bools for some reason. So let’s try this:
public bool Resumed = false;
private void Update() {
if(Input.GetKeyDown(KeyCode.P)){
SaveData.Instance.SavePlayerData();
Debug.Log("Saving Data...");
}
if(Input.GetKeyDown(KeyCode.Escape) && !gameIsPaused){
pauseMenu.FadeUIIn(fadeTime);
Time.timeScale = 0;
gameIsPaused = true;
}
if(Resume)
if(Time.timeScale = 1 && gameIsPaused)
{
gameIsPaused = false;
Time.timeScale = 1;
Resumed = false;
}
}
public void UnpauseGame()
{
Time.timeScale = 1;
Resumed = true;
}
Now your code should work.
Your resume button only seems to be able to set the timescale, for some reason, and the update function works in setting everything else. Thus, when your UnpauseGame()
method is called, we’ll set it to only set the timeScale
back to [1].
From there, we’ll create an if statement under Update()
to check if the timeScale
is at [1]/normal speed, and if the bool gameIsPaused
is still true.
Then in the If statement, set gameIsPaused
to false.
By the way, it seems like manually pressing Resumed does work, looking at the fact it turns off gameIsPaused
. It’s just that you’ve commented out the code for setting the timescale to normal in both Update()
and UnpauseGame()
instead of only UnpauseGame()
.