Pause Button not working

I have made a GUI pause button, but it is not working.

if (GUI.Button(new Rect(20, 100, 50, 50), pauseTex, new GUIStyle()))
        {
            if (paused) { Time.timeScale = 1.0f; paused = false; }
            else { Time.timeScale = 0.0f; paused = true; print(Time.timeScale); }
        }

This is my code. The button definitely clicks, and it even sets Time.timeScale to 0, but all of my stuff is still running. Everything is dependent on update(), so it should totally work. This code is on the MainCamera, and all the other scripts that I need to stop are on the other things. Is there something I’m doing wrong?

Sometimes it does that, for example, when you’re rotating with transform.Rotate, or moving objects with transform.Translate. tóThe solution I found is, to put a:
if (Time.timeScale == 0)
return;
in the first line of Update

Disgusting. Fix your code.

if (paused)
{
     Time.timeScale = 1.0f;
     paused = false;
}
else
{
     Time.timeScale = 0.0f;
     paused = true;
     print(Time.timeScale);
}

Jesus...

Hey, it could have been …

 Debug.Log(Time.timeScale = ((paused = !paused) ? 0f : 1f));

:stuck_out_tongue:

Actually compact code looks more stylish :smile:

If you have anything useful to say, then next time maybe try that. Maybe he just pasted the code wrong, oooor he don’t want to waste another 9 line for that

That’s disgustingly compact :stuck_out_tongue: