I’ve been working on an Editor Extension that will let people run the NUnit gui application from inside Unity so that it can be used to run unit tests on all of a person’s scripts. After some tweaking to the NUnit source code, I’ve pretty much pulled it off, but there’s one quirk I would like to try and fix:
The problem is that NUnit gui is a windows forms application, and when I create it, Unity seems to consider it an external application, so switching focus to NUnit gui steals focus from Unity and my EditorApplication.update() functions are no longer called until I switch focus from NUnit gui back to Unity. This is a problem for me because the part of the logic that actually runs the unit tests needs to be run from the main Unity thread in order for non-thread safe function calls like Resources.Load() to work correctly. I already figured out how to implement communication between the threads, but if my Unity update() functions are never called when NUnit gui has focus then I have to manually switch focus between them to get Unity to run the tests, then switch back to NUnit gui to see the results, which is annoying, especially if switching focus to Unity causes my NUnit gui to disappear behind the Unity editor window.
The ideal solution would be to have NUnit gui somehow recognized as a child window of the Unity editor (I’m skeptical about whether or not this is even possible). At the very least I would like to try and find a way to swap focus between them automatically, so that Unity gets focus immediately when you decide to run tests, and focus switches back after the test run is complete. Anyone have any ideas?