change value of child ui text element

I have a series of dynamically created objects (coming from a prefab) and I need to change the value of a child ui text element on each one just after they are instantiated.

Here is my current code:

				Transform button = Instantiate(ButtonPrefab);    
				Text ButtonText = button.GetComponentInChildren (Text);
				ButtonText.text = "this be some text!";

This code is giving the error ‘UnityEngine.UI.Text’ is a ‘type’ but a ‘variable’ was expected. What am I doing wrong?

You can use GetComponentInChildren either by passing a type or using the generic version, like so:

 Text ButtonText = button.GetComponentInChildren<Text>();

 Text ButtonText = button.GetComponentInChildren (typeof(Text)) as Text;

Check link: Unity - Scripting API: Component.GetComponentInChildren