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
-
reddtoric
Jul 22, 2019 02:06
Please reopen issue
-
JJChai
Jul 11, 2019 13:22
This is still happening in my project (version 2019.3.0a7).
-
Kamyker
Jun 30, 2019 17:24
It got resolved from Rosalyn side 2 weeks ago, now it's time for Unity to implement it. https://forum.unity.com/threads/feature-request-use-new-diagnosticsuppressor-api-to-suppress-cs0649-on-serializefield.697514/
-
Manoadamro
Jun 28, 2019 15:36
Still a problem in latest version (2019.3.0a4)
[SerializeField] private bool _debug;
"warning CS0649: Field 'SelectTool._debug' is never assigned to, and will always have its default value false"
Please don't say this is by design, a warning should warn the user that they have done something wrong, not that they have done something completely valid but the engine can't handle it...
and if it is by design and everything has to be public, why do we even have the [SerialiseField] attribute?
this feels unfinished to me
-
Zullar
Jun 18, 2019 03:30
This is frustrating. I just upgraded and now I'm getting warnings all over. I want my fields private to encapsulate, and I want them serialized to expose them in the inspector. This shouldn't generate a warning.
-
guneyozsan
May 30, 2019 12:31
The most non-sense "By Design" tag I've ever seen.
This completely makes unable to make use of CS0649 warning, and, it spams the console with hundreds of lines of warnings.Either disable it or fix it. A missing feature is better than a non-working and spamming one!
-
Artifact-Jesse
May 25, 2019 05:41
There is no way this is By Design... Please reopen this issue. It's driving me nuts.
-
AlanMattano
May 08, 2019 15:27
Can Unity make a video about this .Net 4.X problem?
-
Alexees
Apr 26, 2019 12:49
What makes this unnecessarily tedious is the fact that you can use "= default" for every field.
-
MrDude
Apr 21, 2019 06:10
By design, declare your private fields public.
That makes total sense. why is anyone complaining about this?
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.