Skip to content

Commit b07fe79

Browse files
fix: network scene manager UNITY_INCLUDE_TESTS (#1265)
Converting all references of #if UNITY_EDITOR || DEVELOPMENT_BUILD over to #if UNITY_INCLUDE_TESTS Remove a check that no longer is pertinent and had a terrible comment that didn't explain what the check was for or why we didn't create and register the DDOL scene like we normally would.
1 parent a746473 commit b07fe79

File tree

1 file changed

+5
-18
lines changed

1 file changed

+5
-18
lines changed

com.unity.netcode.gameobjects/Runtime/SceneManagement/NetworkSceneManager.cs

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public class NetworkSceneManager : IDisposable
9999

100100
// TODO: Remove `m_IsRunningUnitTest` entirely after we switch to multi-process testing
101101
// In MultiInstance tests, we cannot allow clients to load additional scenes as they're sharing the same scene space / Unity instance.
102-
#if UNITY_EDITOR || DEVELOPMENT_BUILD
102+
#if UNITY_INCLUDE_TESTS
103103
private readonly bool m_IsRunningUnitTest = SceneManager.GetActiveScene().name.StartsWith("InitTestScene");
104104
#endif
105105

@@ -320,22 +320,10 @@ internal NetworkSceneManager(NetworkManager networkManager)
320320
{
321321
DontDestroyOnLoadScene = networkManager.gameObject.scene;
322322
}
323-
else // Otherwise, we have to create a GameObject and move it into the DDOL to get the scene
323+
else
324324
{
325-
326-
#if UNITY_EDITOR || DEVELOPMENT_BUILD
327-
// During unit and integration tests, we could initialize and then enable scene management
328-
// which would make this generate an extra GameObject per instance. The DontDestroyOnLoadScene
329-
// is internal so tests that are using multiInstance and that are moving NetworkObjects into
330-
// the DDOL scene will have to manually set this. Otherwise, we can exclude DDOL stuff completely
331-
// during unit testing.
332-
if (m_IsRunningUnitTest)
333-
{
334-
return;
335-
}
336-
#endif
337-
// Create our DDOL GameObject and move it into the DDOL scene so we can register the DDOL with
338-
// the NetworkSceneManager and then destroy the DDOL GameObject
325+
// Otherwise, we have to create a GameObject and move it into the DDOL in order to
326+
// register the DDOL scene handle with NetworkSceneManager
339327
var myDDOLObject = new GameObject("DDOL-NWSM");
340328
UnityEngine.Object.DontDestroyOnLoad(myDDOLObject);
341329
DontDestroyOnLoadScene = myDDOLObject.scene;
@@ -799,7 +787,6 @@ private void OnClientUnloadScene(uint sceneEventId)
799787
ClientId = m_NetworkManager.LocalClientId // Server sent this message to the client, but client is executing it
800788
});
801789

802-
803790
#if UNITY_INCLUDE_TESTS
804791
if (m_IsRunningUnitTest)
805792
{
@@ -973,7 +960,7 @@ private void OnClientSceneLoadingEvent(uint sceneEventId)
973960
return;
974961
}
975962

976-
#if UNITY_EDITOR || DEVELOPMENT_BUILD
963+
#if UNITY_INCLUDE_TESTS
977964
if (m_IsRunningUnitTest)
978965
{
979966
// Send the loading message

0 commit comments

Comments
 (0)