Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Apples_mmmmmmmm · May 03, 2011 at 09:20 PM · errorsyntax-errorbce0044

(10,47): BCE0044: expecting :, found '='.

I'm working on setting up my GUI for my project, and so far everything is going pretty well. However when I tried adding my if statements for my boolean variable TogglleMenu I recieve the error expecting :, found '='. on the 10th line. Any help figuring this problem out would be nice as I'm fairly new to Javascript.

var bannerskin : GUISkin; var ToggleMenu : boolean = false; function Update() { if(Input.GetKeyDown(KeyCode.Escape)) PauseGame(); } static function PauseGame() { if(!ToggleMenu) { { Time.timeScale=0; AudioListener.pause = true; ToggleMenu=true; } else { Time.timeScale=1; AudioListener.pause = false; ToggleMenu=false; } } } function OnGUI() { GUI.skin = bannerskin; //switch to my bannerskin if(Time.time<=10) { GUI.Box(Rect (Screen.width/4,0,Screen.width/2,Screen.height/5), ""); } GUI.skin = null; //switch to default skin if(!ToggleMenu) //if ToggleMenu = true execute follwing, Application.Exit, Prompt Level Select GUI, or unpause game. { if(GUI.Button(Rect (Screen.width/2,Screen.height/2,Screen.width/6,Screen.height/12), "Exit Program")){ Application.Exit; } if(GUI.Button(Rect (Screen.width/2,(Screen.height/2)+(Screen.height/12),Screen.width/6,Screen.height/12), "Level Select")){ //Next Level Select Menu code goes here } if(GUI.Button(Rect (Screen.width/2,(Screen.height/2)+(Screen.height/12)+(Screen.height/12),Screen.width/6,Screen.height/12), "Back To Game")){ Time.timeScale=1; AudioListener.pause = false; ToggleMenu=false; } }

}

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by Bunny83 · May 03, 2011 at 10:25 PM

If i fix the two errors we mentioned above below the only thing that is still wrong is that there's no Exit function in Application. It's called Application.Quit() and you have to put brakets behind it.

Here's the fully working script:

var bannerskin : GUISkin; static var ToggleMenu : boolean = false;

function Update() { if(Input.GetKeyDown(KeyCode.Escape)) PauseGame(); }

static function PauseGame() { if(!ToggleMenu) { Time.timeScale=0; AudioListener.pause = true; ToggleMenu=true; } else { Time.timeScale=1; AudioListener.pause = false; ToggleMenu=false; } }

function OnGUI() { GUI.skin = bannerskin; //switch to my bannerskin if(Time.time<=10) { GUI.Box(Rect (Screen.width/4,0,Screen.width/2,Screen.height/5), ""); } GUI.skin = null; //switch to default skin if(!ToggleMenu) //if ToggleMenu = true execute follwing, Application.Quit, Prompt Level Select GUI, or unpause game. { if(GUI.Button(Rect (Screen.width/2,Screen.height/2,Screen.width/6,Screen.height/12), "Exit Program")){ Application.Quit(); } if(GUI.Button(Rect (Screen.width/2,(Screen.height/2)+(Screen.height/12),Screen.width/6,Screen.height/12), "Level Select")){ //Next Level Select Menu code goes here } if(GUI.Button(Rect (Screen.width/2,(Screen.height/2)+(Screen.height/12)+(Screen.height/12),Screen.width/6,Screen.height/12), "Back To Game")){ Time.timeScale=1; AudioListener.pause = false; ToggleMenu=false; } } }

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Apples_mmmmmmmm · May 03, 2011 at 10:33 PM 0
Share

Thank's a lot. That solved my problem I was having. (Btw, I just was going off the top of my head for the Application.quit() command, but thanks for bringing it up anyways).

avatar image
2

Answer by Bryan 4 · May 03, 2011 at 09:27 PM

Original code:

if(!ToggleMenu)
{
    {
        Time.timeScale=0;
        AudioListener.pause = true;
        ToggleMenu=true;
    }
    else
    {
        Time.timeScale=1;
        AudioListener.pause = false;
        ToggleMenu=false;
    }
}

your brackets are mismatched. should be

if(!ToggleMenu)
{
    Time.timeScale = 0;
    AudioListener.pause = true;
    ToggleMenu = true;
}
else
{
    Time.timeScale = 1;
    AudioListener.pause = false;
    ToggleMenu = false;
}
Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Bunny83 · May 03, 2011 at 09:30 PM 0
Share

In addition you have to make Toggle$$anonymous$$enu static in order to use it inside a static function.

avatar image Apples_mmmmmmmm · May 03, 2011 at 09:35 PM 0
Share

Tried switching this out with what I had, and it gave me the following errors:

Assets/Imported from other project/Scripts/other/NewBehaviourScript.js(23,10): BCE0044: expecting (, found 'OnGUI'. Assets/Imported from other project/Scripts/other/NewBehaviourScript.js(23,17): UCE0001: ';' expected. Insert a semicolon at the end. Assets/Imported from other project/Scripts/other/NewBehaviourScript.js(25,18): BCE0044: expecting :, found '='.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

No one has followed this question yet.

Related Questions

BCE0044 error: OnControllerColliderHit 2 Answers

BCE0044: expecting :, found '=' 2 Answers

script error GUI super simple code 3 Answers

SwipeControl package error in unity iPhone 1.7 1 Answer

error help 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges