How do I add the Nullable context in Unity?

59 views Asked by At

I would like to add the global nullable context to my csproj in Unity. Unfortunately it is auto-generated and is constantly overwritten.

After reading some online suggestions, I've tried adding -nullable:enable to a file called csc.rsp at the root folder to no avail.

Running on MacOS 14, Unity 2023.

1

There are 1 answers

1
Mahdi Po On

why do you want to enable it globally? it's possible to define a nullable variable anywhere in c#

just use "?" at the end of the definition of the variable.

for example:

int? vv=null;
float? ff=null;
if(vv==null)
 vv.value=1;
else
 vv.value=2;