Hola, hice un contenedor y estoy metiendo cubos dentro, quiero contar cuantos cubos hay dentro, pero no se como… de cada contenedor, sabiendo que aveces tendra y otras veces no… alguien me puede ayudar…soy nueva en unity
EDITED BY MODERATOR
google translate
Hello , I made a container and I 'm getting into cubes inside, I want to count how many cubes are in, but not as … of each container , knowing that sometimes you will have and sometimes not … someone I can ayudar…soy new in unity
Ok so assuming that i understood from google translate, In order to know the count of the cubes inside a container (Children of that container in the Hierarchy) you simply write this:
“Hello , I made a container and I’m
putting cubes inside. I want to count
how many cubes are inside, but I don’t
know how… with each container,
knowing that sometimes the container
will have things in it and other times
not. Can someone help me? I’m new in
Unity.”
MY ANSWER:
It looks like you can use parentObject.Transform.childCount() to return the number of children of an object. I haven’t used this, but it looks promising. The following code is untested but my compiler Accepted it…
int count = GameObject.Find("Glass1").transform.childCount;
MY ANSWER (TRANSLATED):
Me parece que se puede usar parentObject.Transform.childCount para obtener la cantidad de hijos de qualquier objecto. No lo he usado antes, pero parece prometido. El codigo siguiente no esta probado pero mi compilador lo acepto’…
int count = GameObject.Find("Belt").transform.childCount;