StartCoroutine returns a “Coroutine” object. This object can be yield inside a coroutine to wait for the inner coroutine. Anyways the “nested” coroutine will be a completely seperate coroutine. It you yield a nested coroutine, the outer coroutine just waits for the inner coroutine to finish.
yield return new LerpSize (targetSize, lerpDuration);
from within a different coroutine function to delay execution of code beyond that statement until the statement is finished. In this case LerpSize is a class. This depends on whether inheriting from YieldInstruction (which I haven’t tested to be actually possible!) and LerpSize in this case would be a class with the following constructor:
public class LerpSize : YieldInstruction
{
LerpSize(float targetSize, float lerpDuration) : base()
{
//The lerp sizing function here
}
}
to make the method LerpSize(float, float) run as a coroutine. This means it will run independent of the main application loop and you can yield (wait) inside the method.
IEnumerator LerpSize(float targetSize, float lerpDuration)
{
//Lerp code here
}