The more .cs files are located in the project, the longer the editor needs to enter playmode in an empty scene. I created a test project with 1000 .cs files, which is a reasonable number for a medium real-world project in my experience.
The slowest method when entering playmode, with more than 2-3 seconds in my tests, being BuildPipelineInterfaces.InitializeBuildCallbacks()
. Please see the video that I attached to the bug-report.
Reproduce
- Open user project
- Click File/New Scene
- Open Window/Profiler and enable “Profile Editor” and “Record”
- Press Play
- Once the editor switched to playmode, turn off “Record” in Profiler
- Select the Peak sample in Profiler, find the “EnterPlaymode” entry and expand it down this path:
- In the profiler Profiler drill down to…
Write down “Time ms” for the BuildPipelineInterfaces.InitializeBuildCallbacks() entry.
- Remove all .cs files from the project
- Repeat the test
Observe that without .cs files in the project, BuildPipelineInterfaces is a lot faster (100x faster in my tests).
Expected
The number of .cs files in the project should have no affect on how long the editor needs to EnterPlaymode. In this case, BuildPipelineInterfaces should not get slower the more files are in the project.
Ideally, BuildPipelineInterfaces.InitializeBuildCallbacks() should not be called during EnterPlaymode at all, but during builds only.