Answer the question
In order to leave comments, you need to log in
Is there any point in checking activeInHierarchy?
I often have this piece in my code
if(obj.gameObject.activeInHierarchy){ obj.gameObject.SetActive(false); }
....
if(!obj.gameObject.activeInHierarchy){ obj.gameObject.SetActive(true); }
obj.gameObject.SetActive(false);
....
obj.gameObject.SetActive(true);
Answer the question
In order to leave comments, you need to log in
There is one good rule for any popular frameworks: don't try to be smarter than them. Unity does not slow down in speed if you turn on an enabled object or turn off a disabled one, all checks are already enabled inside these functions. And in the examples above, only clogging the code with unnecessary checks.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question