- Home /
Deactivate Instantiated child Objects not working
Hey guys,
I am instantiating an object and making it the child of a parent object in game and setting it to the GUI layer (to be seen just by GUI).
GameObject item = Instantiate(obj) as GameObject;
item.layer= 8; //GUI Layer
item.transform.position = transform.FindChild("Path").position;
item.transform.parent = transform.FindChild("path");` Now however when I SetActiveRecursively(false) the parent, the dynamically added object does not get de-activated. it still stays active...
Any ideas?
Answer by nomadic · Jun 03, 2012 at 06:05 AM
How are you calling SetActiveRecursively? You said the Instantiated child is not getting deactivated, is the parent object also not being deactivated?
From what I can tell, this should work:
item.transform.parent.gameObject.SetActiveRecursively(false);
I was having a similar problem but this worked for me.
Your answer
Follow this Question
Related Questions
in-editor cloning of game objects 1 Answer
Instantiate fails with no errors 0 Answers
Instantiate rigidbody, transform or gameobject? 1 Answer
Convert FileStream to Gamobject? 0 Answers
Destroying an Instantiated GameObject 4 Answers