Search Unity

Coroutine bug not logging any error

Discussion in 'Editor & General Support' started by Wulirocks, Jul 2, 2022.

  1. Wulirocks

    Wulirocks

    Joined:
    Mar 18, 2013
    Posts:
    63
    That line of code stops or kills the coroutine, and Unity does not log any error:

    yield return new WaitUntil(() => ChunkLoader.chunksBuilt[HeroStartChunk.x, HeroStartChunk.y] );

    Of course I used a breakpoint to check what was going on...
    When this line is executed:
    ----> ChunkLoader.chunksBuilt lenght is [50,10]
    ----> HeroStartChunk (Vector2Int ) is x = 3 and y = 6
    This is the simpliest line of code ever, yet... something strange happens.

    Since I was puzzled by this, I tried to press the "Step over" arrow button of Visual Studio after the breakpoint was reached..
    and the only thing that proves that something went wrong is that the debugger studently jumps to
    1. namespace UnityEngine.Networking
    2. public class MyCustomNetworkIdentity : MonoBehaviour
    3. where the method UNetStaticUpdate() is called

      This kind of coroutine "silent error" if we may call it that, never happened to me.... I am curious...
     
  2. Wulirocks

    Wulirocks

    Joined:
    Mar 18, 2013
    Posts:
    63
    Solved;

    while (!somethingIsDone) {

    yield return new WaitForSeconds(2f);

    WaitUntil(() => ChunkLoader.chunksBuilt[HeroStartChunk.x, HeroStartChunk.y] );
    }
    Was moving code around and added this WaitUntil inside my while (!somethingIsDone) .... bad idea
     
  3. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,689
    Wulirocks likes this.