Any way to check if an object is active?

I’ve used if(theObject.activeSelf == true){} and if(theObject.activeInHierarchy == true){} but I’m not really sure how to use those, if anyone could help me here that would be awesome!

Also, I need it in C#

Can someone help me on this one?

1 Answer

1

activeSelf will check for the current gameObject
activeInHierarchy will check for the current as well as children of current gameObject

If you want to use activeInHierarchy make sure the child of current gameObject are active

Rest you can read in the docs

I've read the script references, but I'm still a little confused. Is there a way you could give me an example of how you are supposed to use it?

[21282-pic.jpg|21282] check the above screen shot suppose you are checking activeSelf for GameObject_2 it will check whether GameObject_2 is active or not Now if you want to check the state for GameObject_1 as well as its child i.e cube you have to use activeInHierarchy