Say I have the following the code
int i = 0;
void Start()
{
StartCoroutine("Code");
Code2();
}
IENumerator Code()
{
yield return new WaitForSeconds(1.0f);
i = 2;
}
void Code2()
{
print(i);
}
Obviously i is going to print 0, because the code executes Code2 before reaching i = 2. How could I make it print 2 without putting Code2() after the yield return?