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 /
  • Help Room /
This question was closed Oct 20, 2015 at 11:09 AM by meat5000 for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by greg1992 · Nov 03, 2012 at 03:45 PM · parsing error

Unity Parsing error

Hello, i was wondering if you guys could point out what is wrong with this C# code.

using UnityEngine; using System.Collections;

public class PlayerScript : MonoBehaviour {

// Use this for initialization void Start () { } // Update is called once per frame void Update () { } void OnControllerColliderHit(ControllerColliderHit hit) { if (hit.gameObject.name=="machineGun") { Debug.Log("Object picked up "+ hit.gameObject.name); Destroy(hit.gameObject); } }

Comment
Add comment · Show 3
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 ZenithCode · Nov 03, 2012 at 04:27 PM 0
Share

It looks ok. What is the problem?

avatar image greg1992 · Nov 03, 2012 at 05:30 PM 0
Share

Parsing error CS8025

avatar image phodges · Nov 03, 2012 at 05:56 PM 1
Share

Could you format your code? It's difficult to see what might be causing you a problem without this. In particular, it would be good to see where you have line breaks.

2 Replies

  • Sort: 
avatar image
3
Best Answer

Answer by fafase · Nov 03, 2012 at 06:07 PM

You are simply missing a } I think.

 using UnityEngine; using System.Collections;
 
 public class PlayerScript : MonoBehaviour { //1
 
  void Start () { } //Closing
  void Update () { }  //Closing
  void OnControllerColliderHit(ControllerColliderHit hit) { //2
    if (hit.gameObject.name=="machineGun") { //3
       Debug.Log("Object picked up "+ hit.gameObject.name); 
       Destroy(hit.gameObject); 
    } //2
  }//1 

Your code looks like this and you are not closing the class.

Comment
Add comment · Show 3 · 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 ZenithCode · Nov 03, 2012 at 07:06 PM 0
Share

Yep I confirmed it, there was a missing closing curly!

avatar image greg1992 · Nov 03, 2012 at 11:05 PM 0
Share

Thankyou guys, sorry for perhaps the noob question. Just began my rather...awkward? journey into program$$anonymous$$g/scripting.

avatar image fafase · Nov 04, 2012 at 08:48 AM 1
Share

Don't worry, we all started one day and your error is nothing unusual. Some big projects even use program to check the missing brackets.

avatar image
1

Answer by inslayn · Jan 10, 2013 at 10:10 AM

I also got this issue after performing a merge of conflicted files. In that case, Unity was reporting a parsing error, even though all the curly braces were there.

It turned out that the solution for that situation was to copy the contents of the file, then delete it. I then created a new file with the same name and pasted the contents I had copied into it.

Unity was then able to compile it correctly.

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 RharryR · Oct 20, 2015 at 09:52 AM 0
Share

Yep. I often have to do this(every 3 scripts) because unity does not recognize the files. Sure is annoying.

avatar image meat5000 ♦ · Oct 20, 2015 at 11:08 AM 0
Share

You are likely, inadvertantly, adding in characters that look like whitespace but are not whitespace. Dont code in Rich Text Format for example.

Follow this Question

Answers Answers and Comments

15 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

Related Questions

Parsing error, 1 Answer

Hi everyone, stupid me accidently deleted my script and I had to write it again and now there are problems. If someone could help me it would be much appreciated 3 Answers

Invalid PBX project - iOS Build Help! 2 Answers

error CS8025: Parsing error 1 Answer

Parsing error 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