private static void AddTestSceneToBuild() { string scenePath = PlayModeTestRunner.GetTestScenePath(); if (string.IsNullOrEmpty(scenePath)) { Debug.LogError("Cant find test scene"); return; } var scenes = EditorBuildSettings.scenes.ToList(); var allScenes = scenes.Aggregate("", (concated, scene) => scene.path + "; " + concated); Debug.Log("----------- test scene path: " + scenePath + " all scenes amount: " + scenes.Count + " all scene names " + allScenes); if (scenes.Count == 0 || scenes[0].path != scenePath || scenes[0].enabled == false) { if (scenes.Count > 0) { Debug.Log("----------- scenes[0].path: " + scenes[0].path + " scenes[0].enabled: " + scenes[0].enabled); } var index = scenes.FindIndex(s => s.path.Contains(PlayModeTestRunner.TEST_NAME_SCENE)); if (index != -1) { scenes.RemoveAt(index); } Debug.Log("----------- test scene index " + index); scenes.Insert(0, new EditorBuildSettingsScene(scenePath, true)); EditorBuildSettings.scenes = scenes.ToArray(); Debug.Log("------- EditorBuildSettings.scenes " + EditorBuildSettings.scenes.Aggregate("", (concated, scene) => scene.path + "; " + concated)); } }