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 Joseph 3 · Mar 25, 2011 at 08:32 AM · syntax-errorbce0044

BCE0044: (14,47) expecting :, found ','. makes no sense?

var Button1:Texture;

var Button2:Texture; var Button3:Texture; var Button4:Texture;

var myskin:GUISkin;

function OnGUI () { GUI.skin=myskin; }

 if (GUI.Button (Rect ((Screen.width/2)-(Button1.width/2)-10,(Screen.height/2)-(Button1.height/2),300,200),Button1));
     {
     Application.LoadLevel ("Game"),
     }


     if (GUI.Button (Rect ((Screen.width/4)*3-(Button2.width/2)+140,(Screen.height/2)-(Button2.height/2),200,150),Button2)) {
     Debug.Log("Button 2 Pressed");
     }
             if (GUI.Button (Rect ((Screen.width/4)*1-(Button3.width/2)-60,(Screen.height/2)-(Button3.height/2),200,150),Button3)) {
     Debug.Log("Button 3 Pressed");

     }
 }

function Update () { }

Comment
Add comment · Show 1
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 flaviusxvii · Mar 25, 2011 at 12:33 PM 0
Share

$$anonymous$$akes perfect sense. Your code is all jacked up. What on earth is that comma doing after "Application.LoadLevel("Game")"? Don't you want this IF statement to BE in a function somewhere. It's just floating in space... And what about the semi-colon at the end of the line of the first IF statement? That makes no sense at all.

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by Bunny83 · Mar 25, 2011 at 12:02 PM

Never saw that many errors at once:

  1. All GUI stuff have to be inside the OnGUI. I guess the bracket after GUI.skin=myskin; is wrong.
  2. The first button is terminated with a ";". That way the following code is not related to the if statement
  3. The error you get says "expecting ; found ,". After your Application.LoadLevel you have a ","(comma) but you need a ";"(semicolon)
  4. If you don't need the Update function, remove it because it drains performance even when it's empty.
  5. Pick one indent style and keep it.
  6. If you post code here make sure you mark it as "code". There's a button at the top of the edit field (10101). See the Editing-help for more information.

Here's the corrected script:

var Button1:Texture;

var Button2:Texture; var Button3:Texture; var Button4:Texture;

var myskin:GUISkin;

function OnGUI () { GUI.skin=myskin;

 if (GUI.Button (Rect ((Screen.width/2)-(Button1.width/2)-10,(Screen.height/2)-(Button1.height/2),300,200),Button1)) {
     Application.LoadLevel ("Game");
 }

 if (GUI.Button (Rect ((Screen.width/4)*3-(Button2.width/2)+140,(Screen.height/2)-(Button2.height/2),200,150),Button2)) {
     Debug.Log("Button 2 Pressed");
 }

 if (GUI.Button (Rect ((Screen.width/4)*1-(Button3.width/2)-60,(Screen.height/2)-(Button3.height/2),200,150),Button3)) {
     Debug.Log("Button 3 Pressed");

 }

}

Comment
Add comment · 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
0

Answer by AliAzin · Mar 25, 2011 at 08:42 AM

Try this:

var Button1:Texture; var Button2:Texture; var Button3:Texture; var Button4:Texture;

var myskin:GUISkin;

function OnGUI () { GUI.skin=myskin; }

if (GUI.Button (Rect ((Screen.width/2)-(Button1.width/2)-10,(Screen.height/2)-(Button1.height/2),300,200),Button1)){ Application.LoadLevel("Game");

 if (GUI.Button (Rect ((Screen.width/4)*3-(Button2.width/2)+140,(Screen.height/2)-(Button2.height/2),200,150),Button2)) {
 Debug.Log("Button 2 Pressed");
 }
         if (GUI.Button (Rect ((Screen.width/4)*1-(Button3.width/2)-60,(Screen.height/2)-(Button3.height/2),200,150),Button3)) {
 Debug.Log("Button 3 Pressed");

 }
 }

function Update () { }

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 GlennHeckman · May 04, 2011 at 07:35 PM 0
Share

still have floating if(GUI....) statements not found in the OnGUI function. The first if(GUI.Button) has an open bracket and its closing bracket (I assume) is the one way at the bottom .. nesting 2 more GUI.Buttons .. which will never show up except for 1/30th of a second when the first IF is returned True.

This answer is incorrect.

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

Code Not Working. Any Ideas? 2 Answers

Script error. Please Help! 4 Answers

BCE0044: expecting ':' found ';' 1 Answer

Basic on collision play animation code not working 1 Answer

BCE0044: expecting :, found '=' 3 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