Search Issue Tracker

Active

Planned for 2019.3, 2020.1

Votes

52

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

    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.

Comments (70)

  1. 7235883c0e17d85ad807508682564c94?d=mm

    Laurent_Giroud_Nvizzio

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

  2. C3310c2c30b196c8619df64fea5d7a6e?d=mm

    ClausKleber

    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.

    E.g.:
    [SerializedField]
    private GameObject test = null;

  3. 63eb28e1176e9f6c641763274bf6d48e?d=mm

    Ziflin

    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.

  4. 3b7fd7be0a8cfd84d035964c7d262b20?d=mm

    IARI

    Apr 30, 2020 11:18

    six years, seriousely?
    This really needs to be fixxed.

  5. 35b96a6ddb225ade604d05df2a2db598?d=mm

    Kaymax

    Apr 24, 2020 02:32

    reported just right before found out we have open issue, anyway let it be 2

  6. 9ef2dff0164fbaf6448b38060bcd106c?d=mm

    dorbelian

    Apr 23, 2020 13:08

    I understand that it seems to you that you better know what we need, but we really need it, so be so kind as to fix it as soon as possible.

  7. 5bb847a3478809203abcbd37ebb658b6?d=mm

    Inboxninja

    Apr 22, 2020 02:24

    oops! wrong ticket

  8. 5bb847a3478809203abcbd37ebb658b6?d=mm

    Inboxninja

    Apr 22, 2020 02:20

    this has been "postponed" for 6 years. Can we get a fix please?

  9. 06d364cbcfe76a1f3362651493fafb47?d=mm

    TehMightyPotato

    Apr 08, 2020 22:41

    Yeah I imported 50+ scripts from various SDKs and now I can't see any of my actual warnings because of over 200 of those warnings...
    Can you guys please adress this?

  10. D71b64fbaf77030b93856b1a2d402f91?d=mm

    VGMFR

    Mar 05, 2020 09:44

    This issue is really terrible for warning clarity, it's a pain for all our projects. You would make a lot of developers and code cleaners very happy by prioritizing this issue!

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.