Start being called on application Exit and I cannot start trace

I have a strange bug where the Start() method of one of my scripts is being called when the game exits. And I have no clue why it would happen. Specially since start was called already once on the script.
But the bigger problem is that I have no way to do a stack trace so I can’t tell who is causing this to happen. Note. The stack trace works fine with other method, just not the ones called from outside libraries I guess.

Does anyone have some thoughts on how I might be able to debug this?

I am using VS plugin. Latest version of Unity 4.6.1f1

Thanks!

If you’re not debugging using monodevelop you can put a ‘debug.log(“test”)’ in the Start function instead. While running in the editor open the ‘console’ window then exit the game. The ‘test’ log should appear in the console window - if you select that you can see the stack and hopefully where it was called from.

@fwalker Did you ever figure out what was causing this?

@tonemcbride Debug.Log doesn’t give a full stack trace, just where it was called from in code.

This is only happening on one of my objects, and it doesn’t make sense at all. Never seen it before in 5+ years of Unity dev.

I spent all day debugging this. I am learning Inversion of Control (IOC) using Strange and thought I had a problem with that. I had a [ExecuteInEditMode] on a few things and I believe this was the root cause. I removed the attribute and it seems to have resolved Start() being called on exiting. The attribute was in a base class acquiring a base component, yet child classes were using injection and I was getting all KINDS of errors; from UI animations being way off to null references to statically binded objects. Not sure exactly why the attribute breaks it but from now on, I am completely avoiding it. Mind blown!

Hopefully this helps anyone in need.