Skip to content

Commit 019f19c

Browse files
narrowing test runner usage down to presence of test runner object
1 parent 9206577 commit 019f19c

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

Assets/BossRoom/Scripts/Editor/SceneBootstrapper.cs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using UnityEditor;
22
using UnityEditor.SceneManagement;
33
using UnityEngine;
4-
using UnityEngine.SceneManagement;
54

65
namespace Unity.Multiplayer.Samples.BossRoom.Editor
76
{
@@ -35,6 +34,8 @@ public class SceneBootstrapper
3534
const string k_LoadBootstrapSceneOnPlay = "Boss Room/Load Bootstrap Scene On Play";
3635
const string k_DoNotLoadBootstrapSceneOnPlay = "Boss Room/Don't Load Bootstrap Scene On Play";
3736

37+
const string k_TestRunnerObjectName = "Code-based tests runner";
38+
3839
static bool s_StoppingAndStarting;
3940

4041
static string BootstrapScene
@@ -100,13 +101,9 @@ static void DisableDoNotLoadBootstrapSceneOnPlay()
100101

101102
static void EditorApplicationOnplayModeStateChanged(PlayModeStateChange obj)
102103
{
103-
// detects whether playmode has been initiated by a TestRunner Playmode test; if so disable Boostrap loading
104-
for (int i = 0; i < SceneManager.sceneCount; i++)
104+
if (IsTestRunnerActive())
105105
{
106-
if (SceneManager.GetSceneAt(i).name.Contains("InitTestScene"))
107-
{
108-
return;
109-
}
106+
return;
110107
}
111108

112109
if (!LoadBootstrapScene)
@@ -167,5 +164,10 @@ static void EditorApplicationOnplayModeStateChanged(PlayModeStateChange obj)
167164
}
168165
}
169166
}
167+
168+
static bool IsTestRunnerActive()
169+
{
170+
return GameObject.Find(k_TestRunnerObjectName);
171+
}
170172
}
171173
}

0 commit comments

Comments
 (0)