Trying to find() an image in canvas & getting NullReferenceException

I’ve created a canvas with an image inside, and I want to programatically disable the image. Here’s my script:

GameObject.Find("AvatarDefault").SetActive(false);

But this returns an error - NullReferenceException: Object reference not set to an instance of an object. Not sure why, because the object is definitely there, and named correctly.

Hey there. If you have an image in a canvas, then you won’t be bale to setActive. Images as UI elements only responde to enable = true/false. I don’t know why it is like that, but that is how it works