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
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
-
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 -
Resolution Note (fix version 2020.2):
Fixed in 2020.2.0b9
-
Resolution Note (fix version 2020.1):
Fixed in 2020.1.11f1
-
Resolution Note (fix version 2019.4):
Fixed in 2019.4.15f1
-
Resolution Note (fix version 2018.4):
Fixed in 2018.4.29f1
-
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;
-
Sliem001
Sep 09, 2020 08:03
Unity 2020.20b1 Beta
Problem still exists.Please FIX!!!
-
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/
-
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.
-
Johannes_R
Aug 10, 2020 21:18
Unity gives me warning for not initializing my struct member variables. :(
(Unity 2019.4) -
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...
-
jynerso
Aug 03, 2020 03:49
Someday ...
-
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...
-
ModLunar
Jul 16, 2020 13:06
I'm really glad this isn't marked "By Design". Thank you, we need this fixed.
-
KCAR
Jul 10, 2020 16:18
Unity 2020.2a Beta
Problem still exists.
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- Inspector's custom tooltip is displayed incorrectly when the name is truncated in UI toolkit
- Crash on ScriptableRenderLoopDraw when rendering a specific VFX in Play Mode
- The script is not renamed in the Project window when renaming and a compilation Error is present
- Average FPS in Play Mode degradation on a newly created BiRP project when it's upgraded from 2020.3.48f1 to a newer Editor version
- DecoratorDrawer indentation is incorrect when it is called with EditorGUI
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.