Skip to content

Commit b80b0c3

Browse files
test-fix
Handling a new scenario where a subSystemList can be null.
1 parent 7c87a87 commit b80b0c3

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

com.unity.netcode.gameobjects/Tests/Runtime/NetworkUpdateLoopTests.cs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using System;
22
using System.Collections;
3-
using System.Linq;
3+
using System.Collections.Generic;
44
using NUnit.Framework;
55
using Unity.Netcode.TestHelpers.Runtime;
66
using UnityEngine;
@@ -41,9 +41,10 @@ public void RegisterCustomLoopInTheMiddle()
4141
PlayerLoop.SetPlayerLoop(curPlayerLoop);
4242

4343
NetworkUpdateLoop.UnregisterLoopSystems();
44-
44+
var subSystemArray = PlayerLoop.GetCurrentPlayerLoop().subSystemList[0].subSystemList;
45+
var lastType = subSystemArray[subSystemArray.Length - 1].type;
4546
// our custom `PlayerLoopSystem` with the type of `NetworkUpdateLoopTests` should still exist
46-
Assert.AreEqual(typeof(NetworkUpdateLoopTests), PlayerLoop.GetCurrentPlayerLoop().subSystemList[0].subSystemList.Last().type);
47+
Assert.AreEqual(typeof(NetworkUpdateLoopTests), lastType);
4748
}
4849
// replace the current PlayerLoop with the cached PlayerLoop after the test
4950
PlayerLoop.SetPlayerLoop(cachedPlayerLoop);
@@ -94,7 +95,14 @@ public void UpdateStageSystems()
9495
for (int i = 0; i < currentPlayerLoop.subSystemList.Length; i++)
9596
{
9697
var playerLoopSystem = currentPlayerLoop.subSystemList[i];
97-
var subsystems = playerLoopSystem.subSystemList.ToList();
98+
// New behaviour (6000.6.x)
99+
// Some PlayerLoopSystems can evidently now have no sub-system lists.
100+
if (playerLoopSystem.subSystemList == null)
101+
{
102+
// Ignore any PlayerLoopSystem with no sub-system lists.
103+
continue;
104+
}
105+
var subsystems = new List<PlayerLoopSystem>(playerLoopSystem.subSystemList);
98106

99107
if (playerLoopSystem.type == typeof(Initialization))
100108
{

0 commit comments

Comments
 (0)