- Home /
Count the number of children with a certain component
I'm sure its pretty easy but I can't figure it out. I found a lot of really close answers but not something as specific.
I have a object with several children. Some have a certain component (Obj_Properties) attached and other don't. I would like to get the total number of children that have the selected component.
I know if I do this:
loadOut = transform.GetComponentsInChildren(Obj_Properties);
I get the list of the children with the component but then how can I transform that into an actual number so that I can assign it to a variable?
thanks for any help!
Answer by castor · Oct 04, 2012 at 03:57 AM
Duh, found it!
loadOutTotal = loadOut.Length;
Answer by wiiarethesound · Oct 04, 2012 at 03:58 AM
Should just be:
int size = loadOut.Length;
Aww, I just got this out of the moderator que for you, but it was too late ! I shall upvote both answers =]