- Home /
How do I get the child of every item on an array and save it as an independent GameObject?
I have a Buttons array, every of which has a GameObject as a child. I want to save every GameObject as a separate array,I Have an array of Buttons Display[], every of which has a GameObject as a child. I want to, by script, save every GameObject independently in a separate array
Answer by Mrintoxx · May 27, 2020 at 02:43 PM
I think with a for loop like so, supposed the script is attached to the :
for (int i = 0; i < Display.Length; i++)
{
GameObject newobj = transform.GetChild(i).gameObject;
displays[i] = newobj;
}
I'm not sure that is what you want, tell me if not.
Your answer
Follow this Question
Related Questions
Having trouble using SendMessage 1 Answer
Point Counter Works Only Once! 1 Answer
how to allow the key to only open 1 door rather than all of them? 0 Answers
How do i make the camera smoothly lock to my player? 1 Answer
Having trouble coding an on/off toggle for an animation in script. Please help! 1 Answer