- Home /
GameObject Parent & Child Visibility
Hello Crew, I have a camera moving around a landscape and when it passes an invisible plane Trigger it activates a Game Object I assign in Inspector that Game Object (which has a lot of different things in it : Text, planes with Textures and models etc) I uncheck in the inspector to make it not active My script (.js) below is triggering all the correct messages in Console but not toggling the Game Object (& children's) visibility
#pragma strict
var myVisible : GameObject;
var isTextureVisible : boolean = false;
var theCollision;
function OnTriggerEnter (other : Collider) {
Debug.Log("collision");
if (myVisible.activeSelf==false) {
Debug.Log("true");
myVisible.SetActive(true);
}
else if (myVisible.activeSelf==true) {
Debug.Log("false");
myVisible.SetActive(false);
}
}
Thanks All ~be
Not sure if this is the issue because I can't see your full setup, but GameObjects can only become active if their parent is active. $$anonymous$$ake sure all objects in the hierarchy are active if you want the child to be visible
Thanks mwbranna The parent GameObject ("myVisible") toggles on & off ... it is empty but for the things it holds
Which are all set to visible, so when the parent is turned on (I get the debug.Logs) why aren't the children underneath beco$$anonymous$$g visible / invisible with it?
Appreciate it
~be
Aha!
Script Works √
I had an extra collider on the plane as well as the camera! Oy
~be