Question by
biowolves · May 25, 2016 at 07:08 PM ·
gameobjectparentactive
Check if gameobject set to active regardless of its parents settings?
Hi, I am wanting to check if a gameObject is active regardless of everything else in the hierarchy. example: So if I had A (disabled) with children B (disabled) and C (enabled) when called on B I want it to return false when called on C I want it to return true
Can someone please tell me if there is a way to do this? I have tried "gameObject.activeSelf" but it didn't seam to work.
Comment
I don't think that's possible unless you save it's state yourself somehow. For example if you don't use the SetActive function as it is ins$$anonymous$$d you create a function that does it and saves the state. For example:
bool state = true;
public bool State {
get {
return state;
}
set {
state = value;
gameObject.SetActive(value);
}
}
and in another script:
$$anonymous$$yClass myClass; //assigned through inspector
void Start() {
myClass.State = false;
//or quiery it like activeSelf
}