How to disable a gameobject completely?

Hi, I have an array of gameobjects and I want to use these one at a time.
But, I noticed that the gameobjects, I disable using SetActive(false), components are still alive. The scripts are running for example.
I would like to know how to disable completely without removing from the scene because I don’t like to instantiate every time I have to use them.

Thanks

You can still invoke methods on scripts when they or their host object is ‘inactive’ but the MonoBehavior calls are not made.

If you have this happening, maybe do a check on your methods to see if (gameObject.activeSelf) before running the function.

2 Likes

what happen with the box collider, sprite renderer and animator (components I have in the prefab) ? They are stilll active but are they processing something?
Thanks

No. They’re not doing anything if the host gameObject is inactive.

1 Like

Awake is still called on scripts even when gameobjects are inactive