S
S
Sergey Panov2018-06-09 13:30:21
C++ / C#
Sergey Panov, 2018-06-09 13:30:21

How to count the number of child objects?

Good afternoon friends.
There is a parent object that contains child objects. I need to count them. Can you please tell me if this can be done and how?
Thank you.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Victor P., 2018-06-09
@Jeer

Hi, can you show the code?
If you have a class object and you need to count the number of fields, then you need to use reflection (but something doesn’t come to mind why you need it)
If you have arrays or lists, then there are methods for working with them, or you can use linq.

I
ilemontree, 2018-06-09
@ilemontree

transform.childCount + 1

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question