Using Yield in C# but within Update...

I have this 2 methods…

    private IEnumerator TimeBetweenArrowChanges()
    {
        Debug.Log("TIME - ");
        yield return new WaitForSeconds(2f);
        Debug.Log("2 Seconds");
    }

    private IEnumerator UpdateArrowRotation()
    {
        for (int i = 0; i < ArrowRotation.Count; i++)
        {
            Debug.Log("Check");

            yield return StartCoroutine("TimeBetweenArrowChanges");
            gameObject.guiTexture.texture = ArrowRotation[i];
        }
    }

And I use UpdateArrowRotation() in the update and nothing shows in the log, and it won’t let me use the update as a IEnumerator, what should I do?

I don’t use StartCoroutine with strings; I never found stopping them with StopCoroutine predictable enough to use. You don’t need gameObject. before your guiTexture.

void Update () {
	if (condition) {
		StartCoroutine(UpdateArrowRotation());
		condition = false;
	}

}

IEnumerator UpdateArrowRotation () {
	for (int i = 0; i < ArrowRotation.Count; i++) {
		Debug.Log("Check");
		yield return StartCoroutine(TimeBetweenArrowChanges());
		guiTexture.texture = ArrowRotation[i];
	}
}

IEnumerator TimeBetweenArrowChanges() {
	Debug.Log("TIME - ");
	yield return new WaitForSeconds(2F);
	Debug.Log("2 Seconds");
}

Thanks, the only thing is that I need for the UpdateArrowRotation to always run… continuously.

Any thoughts?

If it’s running continuously why even use co-routines? - just have a it as a regular function or a script attached that only does this per update.

Honestly, I don’t know exactly what you’re trying to do; to me, it looks like you just piled on unnecessary complexity. Here’s my best guess at what you actually want:

IEnumerator Start () {
	int i = 0;
	WaitForSeconds wait = new WaitForSeconds(2);
	while (true) {
		guiTexture.texture = ArrowRotation[i];
		i = i == ArrowRotation.Count - 1 ? 0 : i + 1;
		yield return wait;	
	}
}

I have a guiTexture of an Arrow, like this:

And I want to curve the arrow, I have the images in a List, so what I do is after 100ms, change the image to the next stage of the curving.

That’s what I want to do

I got that. What I didn’t understand was why you were filtering that through multiple coroutines.

What about the code from my last post?

If there is another way of doing that without using yield, please tell me how :P.

It needs to wait actually 0.05seconds between each image to change…

I didn’t in any way suggest not using yield. But I do suggest that having two levels of coroutine is unnecessary. I’m not willing to help anymore unless you tell us how the last code example I gave you isn’t the right solution for you.