- Home /
Other
Enable/Disable children / group of objects
I want to be able to enable and disable the children of "Inventory" I tried this: but it doesnt work..
var Items : GameObject[];
Items = GameObject.FindGameObjectsWithTag("ItemUI");
function Start(){
for(var Item : GameObject in Items){
Item.SetActive(true);
}
}
One thing that jumps out is that the line that finds the items should be at the start of the Start function. You can't initialise fields in that way when you declare them.
But apart from that, you'll have to provide more information. "It doesn't work" tells us next to nothing.
your above code is activating all the gameobjects in the start method, you have not tell that how do you want to enable/disable the items ? button click, mouse click ? please be more specific
Follow this Question
Related Questions
Gui.Enable transperancy 4 Answers
Getting an objects Children 1 Answer
Enable/Disable Game Object With GUI Button 1 Answer
Re Enable C# script on camera 1 Answer
how to enable/disable slider VIA script from a prefab 0 Answers