how check if a gameobject is active ?

how check if a gameobject is active ?

on my…:

function Update () {
I need to unity java script check if a GameObject is active
then do something
else
do something

please help
thanks a lot

if (someGO.activeSelf){
x
}else{
y
}

.activeInHierarchy is what you would normally use, as the most equivalent to the old .active property. A GameObject can return true for .activeSelf and still be inactive, which would happen if it’s the child of another GameObject that used SetActive (false). It’s still true for .activeSelf in that case because it didn’t deactivate itself, and it will become active again automatically if the parent object uses SetActive (true).

–Eric

2 Likes