Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Time.timeScale now affects OnGui - how to make a pause screen?

Discussion in 'Immediate Mode GUI (IMGUI)' started by bfoddy, Apr 17, 2013.

  1. bfoddy

    bfoddy

    Joined:
    Mar 27, 2012
    Posts:
    85
    It used to be that OnGui was called every frame regardless of Time.timeScale, which meant you could pause the game and then call up a menu and interact with it. Now OnGui is affected by the timescale, so pausing the game pauses the GUI too. Is there any way around this?
     
  2. User340

    User340

    Joined:
    Feb 28, 2007
    Posts:
    3,001
    what do you mean? i just set the timeScale to 0 and the gui buttons still worked. Can you clarify?
     
  3. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    There hasn't been any change of behavior regarding this. Setting Time.timeScale to 0 never actually "freezes" a game or anything; it still continues to generate frames as fast as possible (potentially limited by vsync), and OnGUI is called every frame regardless of what timeScale is set to. That's proven by this script:

    Code (csharp):
    1. var x = 0;
    2.  
    3. function Start () {
    4.     Time.timeScale = 0;
    5. }
    6.  
    7. function OnGUI () {
    8.     Debug.Log (x++);
    9. }
    --Eric