Hiding a gameObject and its children by programatically changing its layer

So I cannot use gameObject.SetActive(false) because my gameObject becomes permanently disabled and unreachable.

As an alternative I was wondering if changing its layer is a good approach, and then making that layer hidden to my camera?

Is this an accepted solution?
If so would I need to take into account children as well?

Well, why is it permanently disabled and unreachable? Are you disabling it from a script on the object itself? Can you not disable it on another script?

You could move the gameobject off screen if you needed to, but you should be able to disable it and enable it another way.

I will admit I’ve never tried the layer solution, but not sure that is the best approach.

  1. by hide, you just want invisible? Yes, that would work. Noting that the GameObject would still be active, and therefore cost resources to run its various scripts (update, etc).

  2. yes you will have to account for the children as well.

  3. accepted solution? For hiding something from a camera, yes. As I way to disable an object, no.

Thanks. This particular gameObject is loaded from a separate scene. I’m already using a SetActive(false), true from an event handler on this game Object .
While it is active or current I also have another condition that requires to hide and unhide. So switching levels seems like a good alternative.