Is it possible to have a yield manager?

I am not sure why this wont work but, say if I dont want to have my functions all IEnumerators, could I instead have a function what manages yields? It doesnt work when I call it for some reason.

void Awake()
    {
        StartCoroutine("fakeYield", 0);
    }

and this is the function :

IEnumerator fakeYield(float duration)
    {
        Debug.Log("Waiting for "+duration);
        yield return new WaitForSeconds(duration);

    }

and I am calling it like this :

void reArrangeChunkOrderToMatchSystem(int dir)
    {
        GameObject[] newData;
        
        if (dir != 6)
        {

            switch (dir)
            {
                case 0:

                    newData = new GameObject[loadedChunkRadius * worldChunkDefaultLoadedHeight];

                    for (int i = 0; i < loadedChunkRadius * worldChunkDefaultLoadedHeight; i++)
                    {
                        newData *= ChunkInstance;*

}

int temp = 0;
for (int i = 0; i < loadedChunkRadius * worldChunkDefaultLoadedHeight * loadedChunkRadius; i++)
{

Vector3 a = loadedChunks*.transform.position;*
if (a.x == centerChunk.pos.x - 96)
{
fakeYield(0.1f);
loadedChunks_.transform.position += new Vector3(16 * (loadedChunkRadius - 1), 0, 0);
Vector3 vec = new Vector3(loadedChunks.GetComponent().chunk.pos.x, loadedChunks.GetComponent().chunk.pos.y, loadedChunks*.GetComponent().chunk.pos.z);_
_reloadChunkDataOrGenerateNew(vec, loadedChunks);
temp++;
}*_

}

break;
It debugs it once, during the awake function for some reason and whenever the loop calls it, it doesn’t call the function for some reason…

Your fakeYield function is a generator function. It doesn’t execute any code inside your function, but it returns and object which can be used to “iterate through your code”. This object need to be passed to StartCoroutine and Unity’s coroutine scheduler will handle the iteration for you.

When you just call:

fakeYield(0.1f);

It will create an iterator object which you just throw away, so it does nothing. Besides that your fakeYield has no use since there’s nothing after your

yield return new WaitForSeconds(duration);

The reArrangeChunkOrderToMatchSystem function can’t be “paused” since it’s not a coroutine.

What do you actually want to do?