Count multiple objects!


I have a problem.
I want to count multiple objects, but how do I do this?
I’ve searched a lot on this website, but I could not find anything.
He must count the cubes (a tag I can give them if necessary), and if there are 0, he must do something.
For example Debug.Log(“Hey”);

Does anyone know how you do that?

I’ve always seen Unity as a she, never the less -

You can do something like this:

function Start () {
	if(CountCubes()==0) {

function CountCubes () : int {
    var cubes : GameObject[] = GameObject.FindGameObjectsWithTag("cube");
    return cubes.Length;

But it’s far better to keep track of quantities by adding or subtracting a single integer when you spawn or remove objects.

Sorry, but it does not work :frowning:


====( )=====

The website wholesale for many kinds of fashion shoes, like the nike,jordan,prada,****, also including the jeans,shirts,bags,hat and the decorations. All the products are free shipping, and the the price is competitive, and also can accept the paypal payment.,after the payment, can ship within short time.

Air jordan(1-24)shoes $30

Handbags(Coach l v f e n d i d&g) $35

Tshirts (Polo ,ed hardy,lacoste) $15

Jean(True Religion,ed hardy,coogi) $30

Sunglasses(Oakey,coach,gucci,A r m a i n i) $15

New era cap $12

Bikini (Ed hardy,polo) $20

accept paypal and free shipping

====( )=====

====( )=====

====( )=====

====( )=====

====( )=====

====( )=====