I have this property:
public bool Show
{
get
{
try
{
if (gameObject != null)
{
return gameObject.activeSelf;
}
else
{
return false;
}
}
catch (Exception e)
{
Debug.Log("how does this even happen?" + e.ToString());
return false;
}
}
set
{
if (value != Show)
{
gameObject.SetActive(value);
}
}
}
being called from within a class that derives from MonoBehaviour. The try block is throwing a null reference exception. This is on a webGL build.
How is this possible? In what cases would a component not have a gameObject assigned to it?