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 zgszft · Jan 18, 2015 at 10:01 PM · c#bugsyntax error

Unity syntax error (I think is bug)

Yesterday when I coding the script, the computer automatic shut down. Then when I opened the monodevelop after opened Unity, it ask me to reload the automatic save version, I clicked "Yes". After that the Unity report me the syntax error. Such as the { cannot be using at the class and struct, a local variable not exist at current context .I check my script lots of times, I believe there were no any errors there and the script can be compiled at the monodevelop and Visual Studio. Then I try using the comment to located the error caused the unity to report accurately. Finally by move a method to other location (between other two methods), and move the declaration statement for the local variable to other position, the error fixed, but if move to the old position, the error will appear again. (All the processes are saved). So why caused this problem and how to fix it instead my method.

For easy to understand my problem. I show some simple examples below

 public void method_A()
 {
     float a;
     callmethod_B();
     a = xxxxxxxx;
 }

The script show at top is no error in Unity, monodevelop and Visual Studio. But if I change some code, the unity will report an error.

 public void method_A()
 {
     callmethod_B();
     float a;
     a = xxxxxxxx;
 }

The unity will report the error at the "a = xxxxxxxx;". The error said the "a" is not exist at current context

Thanks.

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 zgszft · Jan 18, 2015 at 10:13 AM 0
Share

The only differences between actual code and sample code is the name of variable.

The actual code is:

 public Vector3 get$$anonymous$$oveVectorTo$$anonymous$$ainCharacter()
 {
      if(!this.isDirectionFutherTo$$anonymous$$ainCharacter (currentDirection) && !this.isFontViewHasDetection())
      {
           return currentDirection;
      }
      float [] directions_distances = new float[4];
      
      ..............
      //use of directions_distances, error
     float bestDistance = directions_distances [0] + 1;
     ...............
 }

The script at top caused the error when using the "directions_distances", the error message is "The name 'directions_distances' does not exist in current context"

when I change the position like below, the error disappear

     public Vector3 get$$anonymous$$oveVectorTo$$anonymous$$ainCharacter()
     {
          float [] directions_distances = new float[4];
 
          if(!this.isDirectionFutherTo$$anonymous$$ainCharacter (currentDirection) && !this.isFontViewHasDetection())
          {
               return currentDirection;
          }
          
          ..............
          //use of directions_distances, error
         float bestDistance = directions_distances [0] + 1;
         ...............
     }

0 Replies

· Add your reply
  • Sort: 

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

Make sure levels assets are loaded before switching? 1 Answer

Unity5 build issue, not showing texture. 1 Answer

2D Platformer Bug 0 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