Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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
5
Question by user-672 (google) · Feb 15, 2010 at 11:16 AM · variablecompilingjavascript-specificwarningsdeclaration

Can I get a warning if I (involuntarily) declare a new js variable in an assignment?

If I mistype a variable in an assignment a new variable is created. That is a vary nasty situation, as it is hard to find.

Can I make Unity accept only variables when declared with a leading var? If not, can I get warnings?

Thanks, Flo

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

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by Eric5h5 · Feb 15, 2010 at 11:36 AM

No...Unity used to provide warnings about unused variables in JS in a past version, but doesn't anymore for some reason. (At least not for local variables.) Hopefully they will put this feature back sometime.

Comment
Add comment · Show 5 · 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 cregox · Feb 19, 2010 at 05:28 PM 0
Share

@Eric5h5 Do you think this could be "fixed" by using some manual patch file, or something more automated?

avatar image Eric5h5 · Feb 19, 2010 at 05:42 PM 0
Share

It's up to Unity Technologies to fix it, by doing whatever it is they were doing with their Javascript compiler in Unity 2.1 (I believe that's the last version that had proper warnings about unused variables in Javascript).

avatar image cregox · Feb 19, 2010 at 06:09 PM 0
Share

I wouldn't be so bold about that, Eric. Did you know about this following link? Look at AngryAnt's script: http://answers.unity3d.com/questions/1657/best-strategies-for-not-accidently-editing-whilst-still-running/1668#1668

avatar image Eric5h5 · Feb 19, 2010 at 06:18 PM 0
Share

I'm not sure how that's relevant. An editor script for copying component values doesn't help with script compiling at all.

avatar image cregox · Feb 19, 2010 at 06:30 PM 0
Share

Truth be told, I haven't read it. But I've tested it, and if it can interfere with the interface I've imagined of pre-compiler.

avatar image
2

Answer by JDonavan 1 · Feb 16, 2010 at 12:06 AM

If your script is written in C# you will receive a compiler error when you make a mistake like that. So if you find yourself making this mistake often you might consider switching to C#.

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 JDonavan 1 · Feb 16, 2010 at 03:54 PM 0
Share

Gotta love language fanatics that vote down a valid answer.

avatar image Eric5h5 · Feb 17, 2010 at 07:34 AM 0
Share

It's not a valid answer; the question is specifically about Javascript. It's true that C# doesn't have this problem, but that's not relevant here--Javascript used to not have this problem too. For language debates, use the Unity forums.

avatar image JDonavan 1 · Feb 17, 2010 at 02:16 PM 0
Share

Not interested in a language debate. Simply offering a valid alternative to solve his problem since it can't be solved in javascript.

avatar image cregox · Feb 19, 2010 at 05:25 PM 0
Share

@JDonavan I think the problem is the way you said it. But I agree it's a valid answer - the OP doesn't seem to be aware that C# doesn't have this issue.

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

Custom variable declared in JS, that isn't in plugins. 1 Answer

Accessing Variables (again) 2 Answers

C# - Simple Optimization / Variable Declaration 1 Answer

UnityException: You are not allowed to call this function when declaring a variable. Move it to the line after without a variable declaration 1 Answer

What are the best practices to convert variable type? 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