- Home /
Question by
ninjaboynaru · Jul 18, 2013 at 06:07 PM ·
javascriptinventoryitemsfor loophow many
Get the number of items for loop returns
How would i get the number of objects/items that the for loop finds that have met the conditions.
Ammo is a class that extends the Item class
var inv = new List.<Item>();
function OnGUI(){
for(ammo : Item in inv){
switch(ammo.itemType){ //itemType is teh varible that represents the objEnum
case objType.ammunition: //objType is an enum inside the item class
GUILayout,Button(ammo.icon);
}
}
}
How would I get or return the number of ammo whose itemType have met the condition in the for loop
Comment
Best Answer
Answer by perchik · Jul 18, 2013 at 06:33 PM
...create an integer before the loop, set it to zero, and add one to it every time something meets your condition?
Your answer
Follow this Question
Related Questions
How long should it take me to make my game 2 Answers
I need help fixing my inventory sorting script. 1 Answer
Script Not Working 0 Answers