Search Unity

Pause Game Error message.

Discussion in 'Scripting' started by popmog78, Jan 24, 2011.

  1. popmog78

    popmog78

    Joined:
    Jan 19, 2011
    Posts:
    154
    This is the error message I am receiving when I pause the game?

    BCE0044: expecting :, found ';'.

    This is the code.
    Code (csharp):
    1.  
    2. var paused : boolean = false;
    3. var windowWidth : int = 150;
    4. var windowHeight : int = 200;
    5. var windowRect : Rect = Rect( Screen.width/2 - windowWidth/2, Screen.height/2 - windowHeight/2, windowWidth, windowHeight );
    6.  
    7.  
    8. function Update ()
    9. {
    10.  
    11. if(Input.GetButtonUp("Fire3")){
    12.     if(!paused){
    13.     Time.timeScale = 0;
    14.     paused = true;
    15.     }
    16.  
    17. else
    18. {
    19. paused = false;
    20. Time.timeScale = 1;
    21. }
    22. }
    23. }
    24.  
    25.  
    26.  
    27.  
    28. function OnGUI()
    29. {
    30.    if( paused )
    31.    {
    32.       // 3rd parameter is the function where you will place all your GUI controls that should be in the window
    33.       GUI.Window( 0, windowRect, PausedWindow, "Paused" );
    34.    }
    35. }
    36.  
    37. function PausedWindow()
    38. {
    39.    //all your buttons or other gui components for your window go here, for example:
    40.    GUI.Button( Rect( 5, 10, 70, 20 ), "Main Menu" );
    41.    {
    42.        Application.LoadLevel(1);
    43.    }
    44. }
    45.  
    46.  
     
  2. kfrench16

    kfrench16

    Joined:
    Mar 22, 2009
    Posts:
    73
    if(Input.GetButtonUp("Fire3"))
    {
    if(!paused)
    {
    Time.timeScale = 0;
    paused = true;
    }
    } <---------------------------------------------------This is Missing
    else
     
  3. popmog78

    popmog78

    Joined:
    Jan 19, 2011
    Posts:
    154
    Thanks kfrench16
     
  4. popmog78

    popmog78

    Joined:
    Jan 19, 2011
    Posts:
    154
    I still did it and got the same error message.


    Code (csharp):
    1.  
    2. var paused : boolean = false;
    3. var windowWidth : int = 150;
    4. var windowHeight : int = 200;
    5. var windowRect : Rect = Rect( Screen.width/2 - windowWidth/2, Screen.height/2 - windowHeight/2, windowWidth, windowHeight );
    6.  
    7.  
    8. function Update ()
    9. {
    10.  
    11. if(Input.GetButtonUp("Fire3")){
    12.     if(!paused){
    13.     Time.timeScale = 0;
    14.     paused = true;
    15.     }
    16. }
    17.  
    18. else
    19. {
    20. paused = false;
    21. Time.timeScale = 1;
    22. }
    23. }
    24.  
    25. function OnGUI()
    26. {
    27.    if( paused )
    28.    {
    29.       // 3rd parameter is the function where you will place all your GUI controls that should be in the window
    30.       GUI.Window( 0, windowRect, PausedWindow, "Paused" );
    31.    }
    32. }
    33.  
    34. function PausedWindow()
    35. {
    36.    //all your buttons or other gui components for your window go here, for example:
    37.    GUI.Button( Rect( 5, 10, 70, 20 ), "Main Menu" );
    38.    {
    39.        Application.LoadLevel(1);
    40.    }
    41. }
    42.  
    43.  
     
  5. popmog78

    popmog78

    Joined:
    Jan 19, 2011
    Posts:
    154
    Assets/Standard Assets/Scripts/Paused.js(38,32): BCE0044: expecting :, found ';'.
     
  6. MegadethRocks

    MegadethRocks

    Joined:
    Dec 12, 2009
    Posts:
    162
    Code (csharp):
    1. GUI.Button( Rect( 5, 10, 70, 20 ), "Main Menu" );
    2.    {
    3.        Application.LoadLevel(1);
    4.    }
    5.  
    should be
    Code (csharp):
    1. if (GUI.Button( Rect( 5, 10, 70, 20 ), "Main Menu" ))
    2.    {
    3.        Application.LoadLevel(1);
    4.    }
    5.  
     
  7. popmog78

    popmog78

    Joined:
    Jan 19, 2011
    Posts:
    154
    Thanks MegaDethRocks.
     
  8. popmog78

    popmog78

    Joined:
    Jan 19, 2011
    Posts:
    154
    The menu is working. However,when I press the Letter P for the pause button, it will not stay on the screen. It pops up and then leaves.


    Code (csharp):
    1.  
    2.  
    3. function Update ()
    4. {
    5.  
    6. if(Input.GetButtonUp("Fire3")){
    7.     if(!paused){
    8.     Time.timeScale = 0;
    9.     paused = true;
    10.     }
    11. }
    12.  
    13. THis is the top part of my code.
    14.