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. blankatmcard2022

    Mar 17, 2022 00:22

    GET RICH WITH BLANK ATM CARD ... Whatsapp: +18033921735

    I want to testify about Dark Web blank atm cards which can withdraw money from any atm machines around the world. I was very poor before and have no job. I saw so many testimony about how Dark Web Cyber hackers send them the atm blank card and use it to collect money in any atm machine and become rich.(dwchzone@gmail.com) I email them also and they sent me the blank atm card. I have use it to get 250,000 dollars. withdraw the maximum of 5,000 USD daily. Dark Web is giving out the card just to help the poor. Hack and take money directly from any atm machine vault with the use of atm programmed card which runs in automatic mode.

    You can also contact them for the service below

    * Western Union/MoneyGram Transfer Hack

    * Bank Transfer Hack

    * PayPal / Skrill Transfer Hack

    * Crypto Mining Hack

    * CashApp Transfer Hack

    Email: dwchzone@gmail.com

    Text & Call or WhatsApp: +18033921735

  2. Bip901

    Sep 23, 2020 15:37

    Solution: explicitly assign the default value to the field. E.g:

    [SerializeField] private Collider myCol;

    Becomes:

    [SerializeField] private Collider myCol = default;

  3. Sliem001

    Sep 09, 2020 08:03

    Unity 2020.20b1 Beta
    Problem still exists.

    Please FIX!!!

  4. miniwolf_unity

    Sep 01, 2020 11:36

    We are investigating how to solve this. I would encourage you to add your thoughts and opinions to this thread: https://forum.unity.com/threads/suggesting-solutions-for-serializefield-warning.962112/

  5. darthdeus

    Aug 24, 2020 18:39

    Please fix this :( I wonder if there's some reason why this is difficult, or if Unity just prioritizes adding more features over fixing minor annoyances. I'd imagine since the compiler can see the actual attribute [SerializeField] it shouldn't be hard, but maybe I'm missing something.

  6. Johannes_R

    Aug 10, 2020 21:18

    Unity gives me warning for not initializing my struct member variables. :(
    (Unity 2019.4)

  7. VGMFR

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

  8. kyuskoj

    Aug 03, 2020 03:49

    Someday ...

  9. antonsem

    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: https://www.anton.website/suppressing-warnings-in-unity/

    I would love to see it fixed...

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.