when using a foreach loop in Unity I need to call this in the update method. So it's called once per frame...
I want to know, if it is better to check the count of the list before using the foreach loop or if it is redundant.
So I have
if (myList.Count > 0)
{
foreach (Type type in myList)
{
}
}
and
foreach (Type type in myList) // no need for a check before
{
}
I could also use
for (int i = 0; i < myList.Count; i++) // use a for loop instead
{
myList[i].DoSomething();
}