G
G
Gregory2562021-08-15 15:59:00
C++ / C#
Gregory256, 2021-08-15 15:59:00

How to access a child object and get the data of the script hanging on it?

How to access a child object and get the data of the script that hangs on it? The object is inactive.
Through gameObject.Find does not see.

private TextBehavior textScript;
private void Start()
    {
        textScript = GameObject.Find("TargetText").GetComponentInChildren<TextBehavior>();
        textScript.UpdateScore();
    }

611912f47cfa7463801351.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
Loli E1ON, 2021-08-15
@Gregory256

this.gameObject.transform.GetChild(0).GetComponent<TextBehavior>();

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question