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
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.
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!