Y
Y
yraiv2022-02-10 16:29:58
Unity
yraiv, 2022-02-10 16:29:58

How to turn off a child object in a newly created object?

In one script, I create an object from a prefab, inside of which there are a bunch of child objects, and among them there is 1 that I need to turn off. How is it implemented? How can you refer to a child object just created?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Keliorw, 2022-02-11
@yraiv

It would be more convenient if you threw off the script that creates this object.
But alternatively you can use the following script:

var object = Instantiate(Prefab, transform, false);
object.transform.GetChild(номер дочернего элемента который нужно выключить)gameObject.SetActive(false);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question