- Home /
How do I get the count of children in a prefab?
I have a prefab that is organized as this: ![alt text][1] [1]: /storage/temp/5453-cap.png
I want to get the number of obstacles. I need something like this:
Section1.Find("obstacles").getChildCount();
Answer by sirival · Dec 02, 2012 at 05:12 PM
If you have a reference to the prefab you could try
prefab.transform.Find("obstacles").childCount;
I managed to do it using this: Prefab.Find("obstacles").GetComponentsInChildren(Transform)-1;
Your answer
Follow this Question
Related Questions
How do I count how many instances of a prefab there are? 3 Answers
How to get the instance of a child in a prefab object? 1 Answer
Two Instances of same Prefab dealing damage to each other. 0 Answers
How do I re-link an object that has unintentionally become detached from prefab? 0 Answers
Script uses transform.position of Prefab instead of Instance 1 Answer