When i’m trying to disable the child object “Icon” of my game object, I get a NullReferenceException but I don’t understand why.
private Text icon;
void Start () {
icon = this.transform.Find("Icon").GetComponent<Text>();
//This is working \/ but not when I add GetComponent<Text>();
Debug.Log(this.transform.Find("Icon").gameObject.name);
//NullReferenceException \/
icon.gameObject.SetActive (false);
}
By the way, there is a 3D text on the Child.