If you want to handle the case where the object is unassigned:
null.if (example == null)
{
// Exit early.
return;
}
// Code that uses example.null check.if (example != null)
{
// Code that uses example.
}Do not use modern null-checking operators1 (?., ??, ??=) to check for null.
If you want to correctly assign the object:
null valuesGetComponent or its variants.Find or its variants.AddComponent or CreateInstance.Camera.main.See Unity null to learn about the specifics surrounding null and UnityEngine.Object types.↩