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 Harry64 · Dec 25, 2014 at 10:16 PM · javascriptunity5upgrade

Upgrading to unity 5... lots of errors... please help.

Sorry that my title does not exactly tell what my problems are but it has to do with the upgrade to Unity 5.

I have hundreds of error messages and the unity API Updating Failed.

I have coded all my scripts in Java.

I got lots of these messages and I dont know how to fix them... like this one:

'UnityEngine.Component.hingeJoint' is obsolete. Property hingeJoint has been deprecated. Use GetComponent() instead. (UnityUpgradeable) 'spring' is not a member of 'UnityEngine.Component'

in my script that would be this line:

 function Update()
 {
     mouseY -= Input.GetAxis("Mouse Y") * mouseSensitivity;
     mouseY = Mathf.Clamp(mouseY,-20,180);
     hingeJoint.spring.targetPosition = mouseY;
 }

the other errors are very similar but instead of ".hingeJoint" there are ".audio" and so on...

can someone please tell me how to rewrite this line so I can eventually fix the other 300 errors....

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

1 Reply

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

Answer by Kiwasi · Dec 25, 2014 at 10:40 PM

The shortcut properties have been removed from Unity 5 to allow for WebGL. To fix the errors you need to change every property to the equivalent GetComponent form. This breaking change was a key reason why its called 5.0 and not 4.7.

Here is the fix for the above code. For the rest its a long slog of refactoring to fix each error. The fix is the same in every case of the error.

  // JavaScript
      GetComponent(HingeJoint).spring.targetPosition = mouseY;

  // C#
      GetComponent<HingeJoint>().spring.targetPosition = mouseY;

Its also worth noting that we were warned about this in the original release announcement for Unity 5.0. Anybody planning to upgrade should start avoiding the short cut properties now. My understanding is that only .transform and .gameObject will continue to work, everything else is gone.

Edite: Someone want to confirm I got the JavaScript syntax right? Thanks

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 Harry64 · Dec 25, 2014 at 10:58 PM 0
Share

now it says in the error:

No Appropriate version of 'UnityEngine.Component.GetComponent' for the argument list'(UnityEngine.Component)' was found.

sooo if I understand you correctly... I cant access the components directly so I will need to access them via GetComponent or via variable like in this case...

var thehingejointthingy : HingeJoint; and replace every "hingeJoint" with "thehingejointthingy"...or something like this... am I right? because it would be stupid to get the Components every Update circle...

avatar image Kiwasi · Dec 25, 2014 at 11:05 PM 1
Share

Sorry, just fixed a typo in my answer. You need to use the capital H in HingeJoint.

You were doing GetComponent every frame in update anyway. This way includes one less method call, so will be slightly more efficient. But you are correct, caching the HingeJoint in a local variable will save on performance.

avatar image Harry64 · Dec 25, 2014 at 11:15 PM 0
Share

You were doing GetComponent every frame in update anyway.

O_o omg you are right. I am so stupid...

thank you sooo much. now I am ready for unity 5.... hopefully... now I have to update almost 2 years of java coding learning in unity so I can move on and make my vision come true.

for all people out there if you have the same problems like I had. here is the solution.

ins$$anonymous$$d of hingeJoint.something = somethingelse;

just create a new variable at the top of your script. var hj : HingeJoint;

and then in $$anonymous$$onoDevelope go to Search/Replace and replace the hingeJoint with the new var name hj.

or if you want you can also just replace it with GetComponent(HingeJoint).something = somethingelse; but the otherway is more efficient.

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

27 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 avatar image avatar image avatar image

Related Questions

Issue with pathfinding after upgrade to Unity 5 1 Answer

help with upgrade system(Getcomponent) 1 Answer

How I can make a simple follow AI in Unity 5? 1 Answer

There is no Spatial Blend in my Audio Source 1 Answer

Monodevelop freezes opening js files after creating new project 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