Search Issue Tracker


Planned for 2019.4, 2020.1



Found in



Issue ID




[SerializedField] fields produce "Field is never assigned to..." warning



1. Open the attached project (
2. Observe the warning in the console

Expected: field with SerializeField attribute do not produce the warning

Reproduced in 2018.3.0a1, 2018.3.0b1, 2018.3.0b2, 2019.1.0a1
Did not reproduce in 2018.2.8f1
Regression introduced in 2018.3.0a1

  1. Response avatar


    Nov 06, 2019

    #pragma warning disable 0649
    // your code
    #pragma warning restore 0649

    Or disable it globally by adding a file named csc.rsp to the root of you Assets folder, e.g. Assets/csc.rsp, with the following contents without quotes.


    This will tell the C# compiler to not emit a warning for CS0649 / unused fields.

    If you have .asmdefs with csc.rsp in your project, then you also need to add the "/nowarn:0649" line to those csc.rsp files.

Comments (77)

  1. D71b64fbaf77030b93856b1a2d402f91?d=mm


    Aug 07, 2020 09:00

    Each new release since a year and a half I'm checking the whole changelog praying that this issue has moved from "Known Issues" to "Release Notes". One day, maybe...

  2. 77c93f8de558bd9b1ca4442fc3db0991?d=mm


    Aug 03, 2020 03:49

    Someday ...

  3. 1ba3a9136eb7b10e279cc74ff0b9a758?d=mm


    Jul 29, 2020 12:59

    It is possible to suppress these warnings with csc.rsp file. But it will suppress legitimate warnings as well. I wrote about it in my blog:

    I would love to see it fixed...

  4. 268e488556c0e9e604ef13d23f63ce62?d=mm


    Jul 16, 2020 13:06

    I'm really glad this isn't marked "By Design". Thank you, we need this fixed.

  5. A79cda4d4ab7e50131a86c3463a8c120?d=mm


    Jul 10, 2020 16:18

    Unity 2020.2a Beta
    Problem still exists.

  6. 0a40fa27a039a2b7dd9ce39fcc2a22e4?d=mm


    Jun 26, 2020 01:39

    Best workaround I've found is to make non public fields protected. It gets rid of the warning and has the added benefit of making it impossible to name mangle serialized fields across subclasses.

  7. B0a582ab5ab2b5826d5b837a053a7fab?d=mm


    Jun 09, 2020 16:22

    People having this issue:
    You can also set the field as public, this way also aligns more with the view of "Component Oriented Programming" as components are not designed to be operated alone, and are not expected to be "self contained"

    There is nothing wrong in using public, and it will help you find other patterns that are neater.

    Purists may think this is wrong. But just think in the project and the best way to make your life easier working on it. You don't have to live to c# compiler developers expectations, you just need to make your game, and make it run good and fast. It is much simpler if you don't have to wonder "should this thing be serializefield private, or public instead".

    I invite you to leave that dogmatic OOP "things shouldn't be public because they're not meant to be edited from outside". Most of the time, you are waisting brain time thinking on that. And when it really matters you will have clear motivations about why you need to do one think or another.

    In the meantime, don't bother and use public.

  8. 7235883c0e17d85ad807508682564c94?d=mm


    May 27, 2020 19:39

    People who are (rightfully) shocked that this is not fixed => PLEASE VOTE FOR THIS BUG.

    Commenting here is not going to help but voting will.
    (If every commenter had voted, it would be long fixed.)

  9. C3310c2c30b196c8619df64fea5d7a6e?d=mm


    May 25, 2020 09:42

    You could simply assign null to the serialized field instead of using a hacky workaround like #pragma warning disable 0649.

    private GameObject test = null;

  10. 63eb28e1176e9f6c641763274bf6d48e?d=mm


    May 16, 2020 20:02

    Argh!! It appears csc.rsp and mcs.rsp files are no longer being read in 2020.1.0b8? Is this another bug with recent changes to Visual Studio Projects?

    * Other VS integration bugs include it randomly deciding to detach from VS such that the default .cs file viewer is used instead of VS when opening scripts from Unity.
    * The VS debugger refuses to start until VS is restarted.
    * And the super annoying "Your project has changed, do you wish to reload?" is back.

    I had none of these problems in 2019.3 until upgrading to 2020.1. Now I end up restarting VS about 30 times a day.

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.