Find all objects that have a specific string.

I have an object that has a string color = "color here"

What I need is to count all objects that have color = "red". Using tags is not an option, there will be A LOT of tags otherwise.

Thanks

Use a loop to loop through all the game objects in the scene.

Give every object a script (You can just put it in the script that has the color thing).

Now, you want to add a getColor(); function, and have that just return the string in the color spot...

function getColor() : String (Or is it string, idr){
    return color;
}

So, when you get the color, you check it in an if statement...

var redCount = 0;
var blueCount = 0;

if(color = "red"){
  redCount++;
}
else if(color = "blue"){
  blueCount++;
}

You should get the point from here =).

Good luck!