// function within a function
void Attack()
{
}
void Battle()
{
}
// coroutine within a coroutine
// the about-to nested coroutine also have to be an IEnumerator method
IEnumerator AttackCoroutine()
{
yield return new WaitForSeconds(1);
Debug.Log("Attack");
}
IEnumerator BattleCoroutine()
{
// call the method using "yield return StartCoroutine(FunctionHere())"
yield return StartCoroutine(AttackCoroutine());
yield return new WaitForSeconds(1);
Debug.Log("Defend");
}
Source: http://answers.unity3d.com/questions/14081/nested-coroutines.html
No comments:
Post a Comment