I believe I made an interesting observation that hopefully helps to solve some of the existing editor overhead performance problems during play mode, which often cause my game to become very laggy and sometimes almost unplayable in the editor ( eg this ).
I observed Unity adds a significant processing cost while holding down keys.
Some key combinations cause the editor performance to drop significantly.
In a first person shooter you navigate through the world via WASD-keys and SHIFT-key to run, which causes the editor to drop performance significantly, just because of holding these keys.
The performance drop depends on the window the mouse pointer is located.
The performance drop is significantly worse while the mouse is over the Hierarchy window than the Game window for example. When testing/playing in the editor, the mouse very often ends up or moves over the hierarchy window.
Holding no Key, Mouse moving in GameView
Holding A, Mouse moving in GameView
Holding Shift+A, Mouse moving in Hierarchy
I’ve recorded a rather lengthy video where I go over these findings, which hopefully helps you to solve these performance drop issues.
Video
Please note that in this test there is no actual game running. It’s an empty project. In a real project, you actually have your 30ms (or whatever) spend on the game. If another 30ms kicks in just for editor keystroke processing, this gets unplayable quickly.
Reproduce
- Open attached project
- Open SampleScene
- Open from main menu “Window > Analysis > Profiler”
- Switch Profiler to Editor mode and start recording
- Press Play
- Hold down “A” key and observe performance in Profiler
- Hold down “Shift+A” key and observe performance in Profiler
- Hold down “Shift+A” key while moving the mouse over the Hierarchy and observe performance in Profiler
Actual
Holding down keys cause a huge performance drop.
Expected
No performance drop.