Debug.log firing late?

I have a huge problem here with my game crashing opun loading a scene. I’m trying to figure out how to fix it by using Debug.log but it seems that it is very late when coming to loading levels. The debug fires only when the level is LOADED not before it starts loading.

Here’s my code:

if(loadingMap == true)
        {
            
            if(animated.TransitionDarkener.isPlaying == false)
            {
                Debug.Log("This doesnt show up untill the level already is loaded");
                Global.playingMap = maps[currentMap].LoadScene;
                Application.LoadLevel(maps[currentMap].LoadScene);
            }
        }

Is there any way to send messages to me WHILST unity is loading

Short answer: no. Unity (the game as well as the editor) runs in a single thread. If “something” freezes the whole application won’t respond. Unity will collect all Debug.Log messages during the frame and will update the console when the frame is done.

The only solution is to roll your own logging system which runs in a sperate thread / application or to write to a logfile manually.

edit
ps: When it’s freezing during a level load, you might have an infinite loop in Awake or OnEnable (maybe even Start) in one of the scripts contained in the scene you’re loading.

pps: Have you checked if you actually reach that point? Does it run when you comment out the Application.LoadLevel?

Make it a coroutine and toss in a yield return null before loading the level? Yes, that is is big pain. Think I’ve done it twice, for ugly bugs.