So in my game I need to pause the game using time.timeScale. The way I do this is when the user presses certain button time.timeScale is reduced by x amount (along with Time.fixedDeltaTime), but when time.timeScale is equal to zero I need to run a function. The problem is that functions won’t run when time is stopped. How might I go about running a function when time.timeScale = 0?
What did you do? Update () is still called when timeScale = 0, and the UI is sure.
public class Test : MonoBehaviour
{
void Update()
{
Debug.Log("Update");
}
private void FixedUpdate()
{
Debug.Log("Fixed Update");
}
private void OnGUI()
{
if(GUILayout.Button("Pause"))
{
Time.timeScale = Time.timeScale != 0 ? 0 : 1;
}
}
}