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
-
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? -
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!
-
AlanMattano
Feb 22, 2020 03:39
I forget and now I return back and look for the solution. takes me 1h. And I'm afraid of giving value = 0 to my 200 variables: I do not know if override the inspector ones. Variables are from imported assets from the asset store.
-
TextusGames
Nov 24, 2019 21:51
Ok. Now we will wait for new Roslyn in unity.
There is a good chance error will be fixed sometime after that. -
unity-marcus
Nov 15, 2019 08:02
This is a really annoying Unity bug still present in 2019.3.0b10. The suggested workarounds are not feasible because I do not want to add pragmas to my entire code base. Using a csc.rsp would suppress all CS0649 warnings including valid ones for non-SerializeField occurrences and is not a valid solution either. Please fix this.
-
nomadic
Nov 12, 2019 22:28
This seems to contradict the best Unity design patterns and even the official example projects. Really hope this is revisited.
Also the csc.rsp file should contain "-nowarn:0649" not "/nowarn:0649" -- or at least that is what is working for my environment.
-
Lorash
Nov 11, 2019 21:14
Microsoft has added the required "magic" to Roslyn so this can be fixed: https://github.com/dotnet/roslyn/pull/36067
-
Gooren
Nov 06, 2019 09:45
-
Toxast
Nov 06, 2019 08:46
Before this "design" I was able to see real issues in the console.
-
mayofunk
Oct 10, 2019 14:47
Really??!!
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.