• 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
2
Question by MasterLG · Apr 12, 2017 at 05:09 AM · script erroride

How to "disable" obsolete Unity 4 (and prior) scripting warnings/errors in Unity 5?

Now that I'm using Unity 5, it would be good to disable all of the obsolete features for warnings I can't use.

For example, I can't use Rigidbody rigidbody as a variable on a MonoBehaviour without declaring it as new, but I can't use the inherited member anyway since it's obsolete.

Is it possible to turn off these warnings (turning them into straight-up compiler errors) and make it so that it's attempting to compile for what I'm actually using, without making me have to use keywords and whatnot to make a compiler happy about things that don't exist anymore?

Comment
Add comment · Show 5
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 hexagonius · Apr 12, 2017 at 06:23 AM 0
Share

The way I do this, whenever I'm desperate to use one of the old names, I wrap the declaration with the following directives:

 #pragma warning enable 108
 Rigidbody rigidbody;
 #pragma warning restore 108

This tells the compiler to ignore CS 108 warnings for that single line. This technique can be used for whatever warning mono or unity is giving you.

I don't know if you can make these errors, but I wouldn't see how that's useful, because then you have to change them what you can do when it's just warnings as well

Show more comments
avatar image tanoshimi · Apr 12, 2017 at 06:50 AM 0
Share

Interesting question, although I had to read it twice to understand. I think ins$$anonymous$$d of "disable all of the obsolete features for warnings I can't use" you meant to say "disable all of the warnings for obsolete features I can't use"?

I don't have an answer, other than to say that if things like the .rigidbody inherited member variable are marked as deprecated, they will be completely removed in a future version of Unity, at which point your warnings will presumeably disappear.

Show more comments
avatar image tanoshimi · Apr 12, 2017 at 07:03 AM 0
Share

You can make all warnings act as errors by adding -warnaserror+ to the Assets/mcs.rsp file. Does that help?

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

66 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 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 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

Expandable hierarchy view for all gameobjects in IDE? 3 Answers

How push the object? 2 Answers

Visual Studio and Unity 2018 1 Answer

renderer.material.color = Color.red; does not work 1 Answer

Error CS1502 in script 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