Closed Will-Carson closed 4 years ago
FWIW, Unity has had the same bug for [SerializeField] if the field has been made private -- and had that issue for YEARS.
There may not be a good solution to this, other than simply adding explicit initializations where possible, and using #pragma to disable warnings where not.
@Rigormortis115 oh, now I know what you meant in discord. the solution is to make your fields 'protected' or 'public'. I do that everywhere in DOTSNET when using [AutoAssign] :)
the warning wasn't always there. previously [SerializeField] didn't have it. they added it around 2018 or so but never fixed it.
closing, let me know if there is any thing else
Describe the bug When using the [AutoAssign] tag, the Unity editor produces a "_ is never assigned to, and will always have its default value of null" warning for the variable that is being [AutoAssign]'d.
To Reproduce Steps to reproduce the behavior:
Expected behavior Ideally, normal usage of tools / features of any library should not produce unnecessary warnings.
Screenshots https://media.discordapp.net/attachments/705707645776035870/741428924499886221/unknown.png?width=812&height=139
Additional context This is technically a normal feature of C# (from what I understand.) However it's unhelpful here. The user can manually suppress these errors a variety of ways, but this introduces more boilerplate code that the user has to write which I think should be avoided.