Accessing subcomponent of instance prefab

Hi,
I want to change the text on a sub-component of an instanced prefab.
I do:

  • GameObject levelItemInstance;
    • levelItemInstance = Instantiate(levelItem);
  • levelItemInstance.transform.localScale = new Vector3(1f, 1f, 0);
    • levelItemInstance.transform.Find(“levelName”).GetComponent().text = “WWWW”;

levelItem has many childs and those also has childs (one of them is levelName). I’m doing correctly?

I got this error (on line 6):

  • NullReferenceException: Object reference not set to an instance of an object

Thanks for your help

Find is not recursive, so it’ll only be looking at the direct children. If you know what the “levelName” is attached to you can pass a “path” into find i.e. Find(“parent/child”)

Thanks I have pass the full path and it works now!