check c# unity inspector field not null code example
Example: check c# unity inspector field not null
public static bool IsNull(this T myObject, string message = "") where T : class
{
if (myObject is UnityEngine.Object obj)
{
if (!obj)
{
Debug.LogError("The object is null! " + message);
return false;
}
}
else
{
if (myObject == null)
{
Debug.LogError("The object is null! " + message);
return false;
}
}
return true;
}