Hello,
I have a question:
I wrote this code:
objectParent = transform.Find("objectName");
if(objectParent != null)
{
if(PlayerPrefs.GetInt(gameObject.name) == 0)
{
objectParent.gameObject.SetActive(true);
}
else
{
objectParent.gameObject.SetActive(false);
}
}
The object objectName is a child of the object with the script, but every time when I run the script I get this error:
NullReferenceException: Object reference not set to an instance of an object.
Can anyone help pleas? I have no idea wehre the mistake is…
Thank you!