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?

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.