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 /
This question was closed Dec 23, 2013 at 12:10 AM by clunk47 for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by CapitanRedRUM · Dec 22, 2013 at 05:54 PM · javascripterror-messagebce0043

[JavaScript Error] BCE0043: Unexpected token:

I'm a noob.. This is the errors i got 1) Assets/Txt.js(2,1): BCE0043: Unexpected token: [.
2)Assets/Txt.js(5,1): BCE0043: Unexpected token: ]. 3)Assets/Txt.js(9,2): BCE0043: Unexpected token: [. 4)Assets/Txt.js(12,2): BCE0043: Unexpected token: ]. I'm doing a start menu for my game.. This is my code

 function OnMouseEnter()
 [
     //change the color of text
     renderer.material.color = Color.red
 ];
 
 
 function OnMouseExit()
  [
     //change the color of text
     renderer.material.color = Color.white
  ];
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

  • Sort: 
avatar image
5
Best Answer

Answer by Statement · Dec 22, 2013 at 05:58 PM

Your immediate problem is that you use [ and ] when you should be using { and }.

Functions doesn't end with ;


I'd strongly recommend that you try to learn how to program with Unitys Javascript.

If you search answers for help on learning Javascript for Unity, you'll find a lot of resources.

Here's one, for example: How can i learn JavaScript (UnityScript) ?


Some things to keep in mind when you look for tutorials or books regarding Unitys JavaScript.

  • It's often called UnityScript, to solve an ambiguity with other languages that are named similarly.

  • So avoid confusion with JavaScript!

  • So avoid confusion with Java!

Hope it helps. Good luck, and pick a nice site to start learning programming.

Comment
Add comment · Show 9 · 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 iwaldrop · Dec 22, 2013 at 06:42 PM 0
Share

But he is using Unityscript. And out of curiosity's sake, what are the reasons that you'd recommend one to learn it over the other languages Unity supports?

avatar image Statement · Dec 22, 2013 at 06:56 PM 2
Share

@iwaldrop: Yes, @CapitanRedRU$$anonymous$$ is using UnityScript. I have not implied that the OP was using any other language. I didn't recommend the OP to switch to another language. I recommended that the OP should reinforce their program$$anonymous$$g knowledge (in UnityScript) by learning the basics (like, the syntax, which is extremely important and one of the first things you should learn).

I will add some emphasis on my answer to try to make that a little clearer.

The reason I recommend that the OP should learn it more thoroughly is to help the OP avoiding getting stuck on basics.

So I tried to be helpful here.

  1. a solution to the current immediate problem was presented.

  2. a method of reinforcing the chosen coding path was presented, to provide a means of self-help to the user.

  3. a warning about common ambiguities was presented so user doesn't spend time reading the wrong tutorials or spending money on buying the wrong kinds of books.

avatar image Statement · Dec 22, 2013 at 07:06 PM 1
Share

If you'd ask me, I wouldn't recommend UnityScript. I think personally that it's far better to learn C# as you can directly make use of your skills outside of Unity and that most (based on my experience working with a range of studios) professional users use C#.

  • Some things are better written in UnityScript than C#.

  • Some things are better written in C# than UnityScript.

  • I have very little experience with Boo, and I won't comment on that.

  • In the end, I've found there are more benefits using C# than US.

  • US has missing features, such as extension methods to name one.

avatar image Dismortus · Dec 23, 2013 at 12:08 AM 2
Share

I agree with @Statement. If you'd look through just one page of the Unity Script Reference, you'd know how to correctly use a function in UnityScript. Check out an example.

avatar image clunk47 · Dec 23, 2013 at 06:40 PM 0
Share

Totally agreed as well. +1

Show more comments
avatar image
3

Answer by clunk47 · Dec 23, 2013 at 12:00 AM

Wrong brackets, and you don't need semicolon after closing bracket. You do however need a semicolon after each "INSTRUCTION (F U @Vexe)".

 function OnMouseEnter()
 {
     renderer.material.color = Color.red;
 }
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 Statement · Dec 23, 2013 at 10:01 AM 1
Share

What's up with the outburst? :-) Did I miss a comment?

avatar image clunk47 · Dec 23, 2013 at 06:38 PM 1
Share

Haha just an inside joke between another user and me. @Vexe saw I called instuctions commands and had something to say about it on facebook. Figured I'd correct myself and tag him is all XD

Follow this Question

Answers Answers and Comments

24 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Javascript Expecting Errors ';' & '=' 0 Answers

Setting Scroll View Width GUILayout 1 Answer

Unexpected token: private. Error. Can anyone help? 2 Answers

Can someone help me fix my Javascript for Flickering Light? 6 Answers

Code Error, help please? 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