Is there a performance gain by checking if an object is active

if (remObjs*.activeInHierarchy)* *{* _remObjs*.SetActive(false);*_ _*}*_
Similar to this code. I’m trying to figure out if unity already has a check to see if the gameobject is active before I set it active again and maybe cause a bunch of extra code to be run.

No, there’s nothing to worry about if you deactivated an deactivated object again or if you activate an already activaed object.

Im most cases however it’s to consider if you can simply avoid a frequent updating of objects. You should rely more on events instead on polling a certain state if possible.

As a side note: activating a deactivated object or deactivating an active object can have quite a performance hit. However it depends on what components it has attached. In general activating / deactivating physics objects (objects with rigidbody / collider) is quite heavy. If you “pool” physics objects you might consider to just disable the renderer and move it far out where it doesn’t hit anything until you need them again.

Also keep in mind when checking “activeInHierarchy” before activating an object doesn’t really make much sense. The current “active setting” of an object should be read with activeSelf. activeSelf directly corresponds to the active state of the object itself. So if activeSelf is false and you call SetActive(true) it is guaranteed that activeSelf is now true. This might not hold true for activeInHierarchy if a parent is also deactivated. So a child can be activated but is still deactivated due to the “active state inheritance”.