I'm almost convinced I'm seeing a bug, but this is an entirely new concept for me, so I need some help to understand what's going on. Here's a somewhat simplified version:
static function Initialize()
{
Debug.Log("EventManager.Initialize() called");
if (initialized) return;
Debug.Log("EventManager.Initialize() 1");
eventQueue = new PriorityQueue();
initialized = true;
Debug.Log("EventManager.Initialize() 2");
DoLoop();
Debug.Log("EventManager.Initialize() 3");
}
static private function DoLoop()
{
Debug.Log("Enter Loop()");
while (true) {
Debug.Log("Top of Loop() loop");
while (eventQueue.Count) {
// do something useful
}
Debug.Log("Before Loop() wait");
yield WaitForSeconds(1.0);
}
Debug.Log("Exit Loop()");
}
What's weird is I never see "Enter Loop()" in the console (or anything from DoLoop()), but I see the "Initialize 1", 2, and 3. If I comment out the while (true) loop, I'll see both the "Enter Loop()" and "Exit Loop()", but otherwise neither. What's going on?