Transform.find problem
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.
Comment
Your answer
Follow this Question
Related Questions
Problems With .rotate behavior 1 Answer
Preventing A Teleporting GameObject From Passing Through Walls 2 Answers
Problem. Pick up and Grab object script, except all objects in scene are picked up instead of one. 0 Answers
Camera isn't move position? Why my camera isn't change position? 0 Answers
Position of empty game objects 1 Answer