In the code below I have the FadeToForEnemy coroutine. How can I make sure FadeToForEnemy has ended before I call WaitForSeconds?
IEnumerator EnemyCycle() {
while (isRepeating)
{
for (int j = 0; j < enemies.Length; j++) {
Enemy currentEnemy = enemies [j];
var _myMaterial = currentEnemy.GetComponent<Renderer>().material;
var _currentFade = StartCoroutine(FadeToForEnemy(_myMaterial, 0f, 1f, currentEnemy.gameObject, false));
coroutinesToStop.Add(_currentFade);
}
yield return new WaitForSeconds (hdTime);
for (int j = 0; j < enemies.Length; j++) {
Enemy currentEnemy = enemies [j];
var _myMaterial = currentEnemy.GetComponent<Renderer>().material;
var _currentFade = StartCoroutine(FadeToForEnemy(_myMaterial, 1f, 1f, currentEnemy.gameObject, true));
coroutinesToStop.Add(_currentFade);
yield return new WaitForSeconds (srTime);
}
}
}