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 user-12150 (google) · Apr 28, 2011 at 05:31 PM · errorsyntax-errorbce0044

ShopScript.Js(49,17): BCE0044 expecting :, found GUI.

Hi i Get this error : ShopScript.Js(49,17): BCE0044 expecting :, found GUI. i cant seem why btw its not my script

var PlayerTalksToShopOwner : boolean = false; var OpenShopGUI : boolean = false; var Player : GameObject; var PlayerLevel : int = 0; var CashAmount : int = 0; var BackGroundPos : Vector2 = new Vector2(10,10); var BackGroundSize : Vector2 = new Vector2(10,10); var ShopContentPos : Vector2 = new Vector2(10,10); var ShopContentSize : Vector2 = new Vector2(10,10); var ButtonSize : Vector2 = new Vector2(10,10); var Button1Pos : Vector2 = new Vector2(10,10); var Button2Pos : Vector2 = new Vector2(10,10); var Price1 : int = 100; var Price2 : int = 200; var Price3 : int = 300; var Price4 : int = 400;

function Awake() { if (Player == null) { //use find with tag or any method you prefere to locate your player } }

function Update () { if (PlayerTalksToShopOwner == true) { CheckPlayersLevel (); OpenShopGUI = true; } }

function CheckPlayersLevel() { LVcheck = Player.GetComponent (PlayerScript); PlayerLevel = LVcheck.Level; CashAmount = LVcheck.Money; }

function OnGUI () { if (OpenShopGUI == true); { //Draw shop interface, start with the background GUI.BeginGroup (new Rect (BackGroundPos.x,BackGroundPos.y,BackGroundSize.x,BackGroundSize.y));

     GUI.BeginGroup(new Rect (ShopContentPos.x,ShopContentPos.y,ShopContentSize.x,ShopContentSize.y));
     //check the players level and open the right shop
     if (PlayerLevel >= 0 && PlayerLevel <= 10)
     {
         //Draw buttons so that you can buy something
         if (GUI.Button (new Rect (Button1Pos.x,Button1Pos.y,ButtonSize.x,ButtonSize.y)) && CashAmount >= Price1)
         {
             //add item you just bought to inventory
             CheckMoney.Money = CheckMoney.Money - Price1;
         }
         if (GUI.Button (new Rect (Button2Pos.x,Button2Pos.y,ButtonSize.x,ButtonSize.y)) && CashAmount >= Price2)
         {
             //add item you just bought to inventory
             CheckMoney.Money = CheckMoney.Money - Price2;
         }
     }
     if (PlayerLevel >= 11 && PlayerLevel <= 20)
     {
         //Draw buttons so that you can buy something
         if (GUI.Button (new Rect (Button1Pos.x,Button1Pos.y,ButtonSize.x,ButtonSize.y)) && CashAmount >= Price3)
         {
             //add item you just bought to inventory
             CheckMoney.Money = CheckMoney.Money - Price3;
         }
         if (GUI.Button (new Rect (Button2Pos.x,Button2Pos.y,ButtonSize.x,ButtonSize.y)) && CashAmount >= Price4)
         {
             //add item you just bought to inventory
             CheckMoney.Money = CheckMoney.Money - Price4;
         }
     }
 }

}

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 Joshua · Apr 28, 2011 at 05:52 PM 0
Share

Please format the code properly. This is unreadable.

1 Reply

· Add your reply
  • Sort: 
avatar image
2

Answer by Bunny83 · Apr 28, 2011 at 06:05 PM

Remove the semicolon at this line...

if (OpenShopGUI == true);


edit
Ok, I've just copied your script into my test project. I've created the two related scripts PlayerScript and CheckMoney. I've added a static var Money to the CheckMoney script. Now Unity just complains about your 4 Buttons. You've just set a Rect where the button should appear but you didn't supply the content. If you look at the scripting reference you will see that a button always needs either a string, a Texture or a GUIContent that is displayed on the button.

After i've added a string to each button all compiler errors are gone. I've never got that second error you mentioned. If you fix compiler errors always start with the first error. In most cases the first error will totally mess up the compiler and further errors will disappear after you fixed the first one.

You should get a bit more familiar with the syntax because that are first-month-mistakes...

Comment
Add comment · Show 4 · 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 user-12150 (google) · Apr 28, 2011 at 07:42 PM 0
Share

That wont work. btw i tried aswell

avatar image Eric5h5 · Apr 28, 2011 at 08:58 PM 0
Share

Yes, it does work. Putting the semicolon there is incorrect syntax and will fail; removing it fixes the problem. You have other problems though.

avatar image user-12150 (google) · Apr 29, 2011 at 12:35 PM 0
Share

When i remove the semicolon error : 31,27 :UCE0001 ";" expected. Insert a semicolon at the end

avatar image Bunny83 · Apr 29, 2011 at 02:35 PM 0
Share

I've updated my answer.

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

Script error. Please Help! 4 Answers

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

Unity MoveAround error 1 Answer

3 java errors on a basic shooting script? 2 Answers

Gun recoil/hitback animation problem 1 Answer


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