How to check if object is active?

if ( == true)
I’m looking for another way to do it because this way gives me a warning message:
warning CS0618: is obsolete

1 Like

I don’t know why but it seems some people can’t give a simple answer they have to act smart or something… Want to make you feel like you aren’t ready… I also know this post is 4 years old… But seriously… Simple answer is

if(gameObject.ActiveSelf == true)

Sorry it took so long… Answers.Unity can be super helpful… And sometimes it makes things worse.

Use activeSelf

print(go.activeSelf ? "Active" : "Inactive");

Also worth checking: SetActive, activeInHierarchy

You can also try the OnEnable method

void OnEnable()
    // code to run

if you have several object in a pool

@jfn73150 thanks man! This helped me a lot! That kind of answers i like!! But just one tiny detail: it worked for me only with a small “a” in Active if(gameObject.activeSelf == true)