Unity3D's 2020.2 release is now supporting C# 8 and nullable reference types. The default way to opt in to this language feature is to put <Nullable>enable</Nullable>
in your .csproj
file, but Unity regenerates .csproj
and removes this line every time it compiles.
Is there a way to insert custom content into my .csproj
, or do I need to fall back to the tedious process of starting every file with #nullable enable
?
I did the configuration that @Fadeway suggested and it works for building within Unity itself (2020.3.15f2). But it does not work when using outside editors (VSCode in my case).
However, by adding a new file named Directory.Build.props
along with you .sln
project file, with the following contents:
<Project>
<PropertyGroup>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>
It works as expected in the editor and does not get overwritten when regenerating the .csproj
files from within Unity
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With