Hi
I am currently manually assigning gameobjects in the editor to variables in my script. However the list of gameobjects keeps getting bigger. I need to hide and show a lot of different objects so I would like to hide all gameobjects when my script is called then add the gameobjects i need for the particular section of the game.
Is there a single line i can use to hide everything without having to manually identify each gameobject?
thanks
If you mean doing that in code, you could just iterate through every item in the array and “hide” them by disabling renderer, for example. So if these objects are on a list, you can hide them all without identifying them yourself.
You could also use tags or the object type (based on a script) to find the objects, and then hide them.
these are objects in the hierarchy - am hoping to avoid lists and arrays! Just want to start with a blank slate each time the script is called and build up based on what i need for that scenario
how would i get the objects into a list or array? Tags sounds interesting if that means assigning all objects to a single group then hiding that group - will research thanks
I’m not sure I fully understand what’s happening here, but you mentioned “sections” of your game. I think it would be easiest to put each “section” of the game under a single empty parent GameObject. Then you could simply activate/deactivate those parents to activate/deactivate a whole “section”.
yes, thank you for explaining it better than I had… this is what I am doing but as I increase the number of parent gameobjects i need to update the code:
public GameObject terrain;
public GameObject Training;
public GameObject Signs;
public GameObject videoStream;
public GameObject voting;
....
Signs.SetActive(true);
Training.SetActive(false);
terrain.SetActive(true);
videoStream.SetActive(false);
voting.SetActive(false);
so instead of having to do all this I would like to