Why is it that putting
Renderer? myRenderer;
generates the error
The type 'Renderer' must be a non-nullable value type in order to use it as parameter 'T' in the generic type or method 'Nullable<T>'
whereas
Vector3? myVector3;
does not?
By way of example, I want to be able to write
void ApplyMaterial(Material material)
{
Renderer? renderer = targetDefinedExternally;
renderer?.material = material;
}
In comparison, the following produces no errors
Vector3? vector;
float? magnitude = vector3?.magnitude;
vector3?.Normalize();
This suggests some Unity types are nullable whereas others aren't. How can I tell which is which? (And is there an elegant way to work around this?)