Using child game objects

In this lecture we create an extra script to attach to the GridSystemVisualSingle which is used to get access to it’s MeshRenderer and subsequently keep an array of references to each of the objects. My initial thought was that we would instantiate the prefabs as children of the GridSystemVisual GameObject and simply loop through the children for the respective references. Is there any disadvantage to this approach?

1 Like

Sure you could do that, but then you’d be wasting tons of GetComponent calls.
And if you cache them, then you end up with pretty much the exact same approach so yeah that would work.

1 Like

Right, thanks I thought so since we’re caching a bunch of references it would be the same but without the neatness of having the Show()/Hide() calls and wrapping that up in the same class.

Thanks, still new to Unity so these clarifications are super helpful and so is learning how to make these kinds of design decisions.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms