Unity Editor crashing when editing scripts referenced from GameObjects

Ok, here's an interesting one for you:

The Unity Editor crashes abruptly when saving scripts while in Play mode.

I have a handful of scripts on GameObjects, and I'm referencing some global vars between them. For example:

Spaceship has a GUI object running all it's GUI functions, and asks a spaceship object's main script if it's moving:

localPlayerMove = FindObjectOfType(typeof(scrPlayerShipMove));
    if ( localPlayerMove.isSteering )

This actually works just fine. I'm not having any trouble with this. The problem is that if I have the game running in Play mode in the editor, and I save any changes to any script in the scene, Unity crashes. If I makes those same changes while not in play mode, the script compiles just fine and the editor is happy as a clam. Also just to be clear, if I comment out my script referencing, the editor does not crash when saving scripts. This also occurs with GetComponent stuff like:


Anyone out there have any clues? I'm a bit puzzled.

My first thought was that somewhere in the script reload process a variable is not getting initialized quick enough and there's a divide by zero or something. Which would partially explain why the 'offending' code works just fine when starting fresh. I've looked around and couldn't find any of these, though.

Generally the only time Unity crashes (and I'm assuming by crash you mean it quits to desktop and not just the game state being wrong), is when you have infinite loops.

You might have some code somewhere that if something is null (which it would be if it's not serializable), it gets into an infinite loop and crashes.

See also this question: http://answers.unity3d.com/questions/1559/edit-and-continue-scripting-destroys-current-state