InvalidOperationException - Anyone else getting this?

Shortly after I started on the test driven development sections of this section, I started to get the following error whenever I tried to play my game in Unity. I think it might have something to do with my test code.

Here’s the error in question:

InvalidOperationException: This cannot be used during play mode, please use SceneManager.CreateNewScene() instead.
UnityEditor.SceneManagement.EditorSceneManager.NewScene (NewSceneSetup setup, NewSceneMode mode) (at C:/buildslave/unity/build/artifacts/generated/common/editor/EditorSceneManagerBindings.gen.cs:46)
UnityEditor.EditorTestsRunner.EditorTestsRunnerWindow.OpenNewScene () (at C:/buildslave/unity/build/Extensions/EditorTestsRunner/UnityEditor.EditorTestsRunner/TestRunner/EditorTestsRunnerWindow.cs:424)
UnityEditor.EditorTestsRunner.EditorTestsRunnerWindow.RunTestsOnUpdate () (at C:/buildslave/unity/build/Extensions/EditorTestsRunner/UnityEditor.EditorTestsRunner/TestRunner/EditorTestsRunnerWindow.cs:393)
UnityEditor.EditorApplication.Internal_CallUpdateFunctions () (at C:/buildslave/unity/build/artifacts/generated/common/editor/EditorApplicationBindings.gen.cs:197)

Is anyone else getting this? If so, could you please tell me how you went about fixing it?

Hello, were you ever able to solve the issue? I’m in the exact same scenario and I am stumped…

The issue was because Ben had the “Run on Recompile” option selected in the Editor Tests Runner tab. Ben really needs to update that video because I spent two hours trying to figure it out as well. Basically Unity Test Tools merged with Unity in a later version then what Ben had so all the tools you need are already come standard with unity with no need to download all that stuff.

Privacy & Terms