Crash on Mac, when switching application

We have built a fairly large framework for the base of our games. We have no issue on PC… However, our mac user experience crashes when switching application after adding part of our framework to their scene.

Steps;

  1. Launch Unity with our framework
  2. Add object, component, script and so on.
  3. Run the game. Stop the game. Continue working in Unity.

Up to that point, everything is fine and work as expected.

Then if he switches application, any application, Unity crashes right away. (Application is not responding) A crash report shows up and we must force quit Unity. If he switches application before the first 3 steps, Unity doesn’t crash.

Well, found out why.

We had a .dll that used System.Windows.Form to get Mouse position when being outside the OnGUI() scope. Sadly, on Mac, calling this - while it does work properly - also creates a crash after the editor switched playstates and you switch application in Mac OSX.

As a work around, we had to implement three different ways of gathering mouse position depending of the tool context; EditorWindow, SceneView and Inspector.