Hey guys,
I’m working on a project that relies heavily on run-time instantiated objects and prefabs. In many cases, some of these objects bring in instantiated children of their own. For these “parent” GameObjects, I’ve created a list that contains references to their children GameObjects.
Some of the variables of these GameObjects need to be referenced across the different objects.
Right now, I have a separate script that needs to be able call a function inside each of the children GameObjects.
To do this, I was thinking of having this script build a list to contain references to all these Gameobjects. It would find the Parent GameObjects, and go through each one’s list of children, adding the references to the new list.
*Except, I suspect this might not be the best way to approach things – Would it be best to modify the scripts that are generating my Parent and Child GameObjects, so that whenever one of them is created, the list is updated? So that the list is “managed” dynamically by each GameObject, rather that generated later by searching the scene?
Really, I’m hoping to understand which of these two approaches would be best. Please feel free to point out any other method that I haven’t considered.
I hope this makes sense.
Thanks,
-Juanelo