this should be easy but why can’t i do this?
public GameObject _EditModePanel;
Text _NameText;
private void Start()
{
GameObject go = Helpers.GetChildGameObject(_EditModePanel, "NameText");
_NameText = (Text)go;
}
_NameText = (Text)go; says cannot convert type unityengine.gameobject to unityengine.ui.text
thanks
What are you trying to do? Get the gameobject name? Or do you want a Text component off the gameobject?
_NameText.text = go.name;
_NameText = go.GetComponent<Text>();
You can’t cast a GameObject to a Text. Text is a component on a GameObject. Not the GameObject itself.
oops, my bad, Text is a component of game object so changed GetChildGameObject to transform and did this
_NameText = Helpers.GetChildGameObject(_EditModePanel, “NameText”).GetComponent();