I am finding it very annoying to just yield in code. I have this :
IEnumerator 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++)
{
yield return new WaitForSeconds(0.1f);
Vector3 a = loadedChunks*.transform.position;*
if (a.x == centerChunk.pos.x - 96)
{
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;
The issue is that it wont wait for 0.1 seconds, it will just literally stop the whole function from working. I dont know whats going on and there are no errors but everything after the yield doesnt work any more. Am i doing something obvious that is wrong?
I also started the coroutine in the start function so it should work.
void Start ()
{
StartCoroutine(“reArrangeChunkOrderToMatchSystem”,6);
}
All i want to really do is add a delay to the part where the yield is currently placed so that it slowly streams the data rather than doing everything in a chunk.
Thanks,