Search Unity

Referencing things inside a prefab?

Discussion in 'Editor & General Support' started by dmennenoh, Sep 1, 2019.

  1. dmennenoh

    dmennenoh

    Joined:
    Jul 1, 2015
    Posts:
    379
    I don't use prefabs too much, but I think they will do what I need to build a dynamic scrollable list. Problem is, I don't really know the right way to reference the components within the prefab.

    For instance, I have an image, a text field, and a button that are all children of an empty GO and that is my prefab. When I instantiate it do I then use GetComponentInChildren to get the image? That seems wrong - and then what if I have two buttons or two images?