Search Issue Tracker

Fixed in 2021.1.X

Fixed in 2018.4.X, 2019.4.X, 2020.1.X, 2020.2.X

Votes

216

Found in

2018.3.0a1

2018.3.0b1

Issue ID

1080427

Regression

Yes

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

Scripting

-

1. Open the attached project (warning.zip)
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. lukaszunity

    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.

    /nowarn:0649

    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.

  1. Resolution Note (fix version 2021.1):

    A list where you can pass additional compiler arguments as well as a toggle to suppress common warnings is added in the Player Settings
    Fixed in 2021.1.0a2

  2. Resolution Note (fix version 2020.2):

    Fixed in 2020.2.0b9

  3. Resolution Note (fix version 2020.1):

    Fixed in 2020.1.11f1

  4. Resolution Note (fix version 2019.4):

    Fixed in 2019.4.15f1

  5. Resolution Note (fix version 2018.4):

    Fixed in 2018.4.29f1

Comments (84)

  1. DrunkenMastah

    Sep 21, 2019 20:52

    This needs a solution. You can't just say "By design" without an actual alternative solution.
    If this is by design then fire your designers and find better ones.

  2. KarolStolaDD

    Sep 20, 2019 10:26

    Reopen this, please...

  3. vElumi

    Sep 18, 2019 11:47

    +1 for reopen....

  4. domFC

    Sep 17, 2019 19:18

    This makes it really hard to see real warnings. Please fix this.

  5. F-N

    Sep 11, 2019 07:32

    Poor design. Really Unity, just fix this...

  6. GrandBOOM

    Aug 29, 2019 15:35

    Please fix this. Yeah its "by desing" but that design in god damn horrible. Its making it harder to see actual warnings.

  7. as3mbus

    Aug 26, 2019 08:27

    i'd love to see better explained resolution please.

    `Or disable it globally by adding a csc.rsp file to your project and adding command line switch to disable the warning. `

    how could you do that ?

  8. VDraks

    Aug 13, 2019 19:06

    Please reopen issue

  9. Simpowitch

    Aug 12, 2019 14:24

    This is litterally the worst resolvement of an issue I've seen. This is an issue and is spamming the console window when it absolutely shouldn't. I would like you to re-open this issue. Pure annoyance.

  10. RKOvlesen

    Aug 09, 2019 06:56

    I do not agree with this solution!

    SerializeField is am important tool to prevent public variables in scripts.
    Having to initialize every SerializeField variable to a default value as a workaround is redundant work, reduces readability and can cause confusion.

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.