Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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 hexagonius · Jun 29, 2017 at 03:00 PM · monodevelopconfigurationserializefield

How to disable SerializeField attribute related warnings/proposals from MonoDevelop?

I've been using MonoDevelop for quite some time now and am now at a point where I'd like to know how to remove the following things from MonoDevelop explicitly for Unity:

  • Variables attributed with [SerializeField] are mostly getting set via inspector unless you know the default shouldn't be 0, then you set a default value. MonoDevelop complains with CS0649, a value never been assigned to. How do you disable this?

  • The same reason results in the suggestion to make the variable a constant, because the interpreter doesn't know about the underlying serialization process. How to disable that?

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
0
Best Answer

Answer by FlaSh-G · Jun 29, 2017 at 09:54 PM

You can disable warnings in C# like this:

 #pragma warning disable 649

You can put them at the top of the file, for example.

Edit: For a global solution, you can add compiler instructions.

  1. Add a text file named mcs.rsp (Mono-CSharp [compiler].ReSPonse [file]).

  2. Add this to the file: -nowarn:649

The nowarn flag works just as the #pragma, with a comma seperated list of warning numbers to ignore.

Another edit: I'd recommend thinking twice before globally disabling these warnings though. They exist for a reason and it might be detrimental to ignore them in all potential situations rather than disabling them deliberately on a case-by-case basis.

Yet another edit: Instead of disabling that warning, I'd recommend using = default on your fields. Like this:

 [SerializeField]
 private int number = default;

Also, note Unity's compiler has slowly gotten updated to allow Unity to suppress the warning automatically for serialized fields, and in some feature update, this won't be necessary at all anymore.

Comment
Add comment · Show 6 · 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 hexagonius · Jul 01, 2017 at 07:27 AM 0
Share

I'm looking for global solutions, because this applies for unity in total.

avatar image FlaSh-G · Jul 01, 2017 at 09:20 AM 0
Share

I edited my answer for a global solution.

avatar image hexagonius FlaSh-G · Jul 01, 2017 at 07:17 PM 0
Share

Nice one. Do you have a suggesting for the const suggestion in cases where the SerializeField attribute is set?

avatar image FlaSh-G hexagonius · Jul 01, 2017 at 10:57 PM 0
Share

If it has a warning number, add it to the list. If not, I have no clue.

Show more comments

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

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

MonoDevelop XML doc comments auto completion 0 Answers

Why does monodevelop sets "pink", nonfunctioning breakpoints ? 1 Answer

Resetting MonoDevelop to default settings... 0 Answers

MonoDevelop doesn't load all source control folders 0 Answers

Where to get MonoDevelop Assemblies 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