How to FindChild RectTransform and access its Text

Im trying to parse my hierarchy and find 3 different labels with a text component on each of them:

labelText = buttonObject.transform.FindChild("Firstname").GetComponent<Text>();
labelText.text = userContactsArray[0]*;*

labelText = buttonObject.transform.FindChild(“Lastname”).GetComponent();
labelText.text = userContactsArray[1];
labelText = buttonObject.transform.FindChild(“Description”).GetComponent();
labelText.text = userContactsArray[2];
But I get error “NullReferenceException: Object reference not set to an instance of an object” as if it does not find the object at all.
Is there difference with RectTransform and transform or why exactly I can not find the object? I tried something like RecTransform.FindChild but without luck. Also in documentation it was saying like (RectTransform)transform.FindChild but it didnt work either.
Thanks in advance :slight_smile:

Flying blind as I don’t have access to Unity but null reference means it can’t find a reference to the object.
Where are you setting the buttonObject or userCOntactsArray?

also you can get the child object by number so

transform.GetChild(0).GetComponent<Text>();

or you could just set transform.

GetChild(0).GetComponent<Text>().Text = userContactsArray...

edit: Man am I ever gonna remember to code with

<Text>

in it in code to stop ot from vanishing!

RectTransform inherits from Transform. Navigating the hierarchy with transform.Find is the same.

I think transform.Find is working well, but GetComponent() is returning null because probably the component you are using in the game object is a , or maybe a