How to know gameObject activated or not?

So I want to make button to turn on/off some gameObject.

gameObject.SetActive(true, false) is just for set.

then how can I know some object is currently deactivated?

for write like,

if(gameObject is currently active)
gameObject.SetActive(false);
else
gameObject.SetActive(true);

Thx,

For a question like this you should get used to using the Unity Script Reference:

thx,

so

if(helpGO.activeInHierarchy)
helpGO.SetActive(false);
else
helpGO.SetActive(true);

That would work as long as it didn’t have parent objects or if did have parent objects and they were always active. Since you are setting helpGo active and inactive, it might be more consistent to use activeSelf.

So is the script a component of the gameObject you want to toggle?

What? I dont understand well.

Yes gameobject itself (help window in my game).

If the gameObject is not Active then it can’t be found so GameObject.Find would work from a script that is not on the actual object. As far as I know any components or children don’t work when it or its parents are not active.

Unless I’m the one confused - lol.

Well, I doubt that at first, but I tried.

Just I attach HelpScript.cs to my help game object (most parent object), and then wrote above function, assign its own help gameObject to helpGO variable.

And access to HelpScript from other script for turn it on/off, and this works.