diff --git a/com.unity.multiplayer.mlapi/Runtime/Core/NetworkUpdateLoop.cs b/com.unity.multiplayer.mlapi/Runtime/Core/NetworkUpdateLoop.cs index f8778668a8..1ef881a18f 100644 --- a/com.unity.multiplayer.mlapi/Runtime/Core/NetworkUpdateLoop.cs +++ b/com.unity.multiplayer.mlapi/Runtime/Core/NetworkUpdateLoop.cs @@ -150,7 +150,7 @@ private static void RunNetworkUpdateStage(NetworkUpdateStage updateStage) } } - private struct NetworkInitialization + internal struct NetworkInitialization { public static PlayerLoopSystem CreateLoopSystem() { @@ -162,7 +162,7 @@ public static PlayerLoopSystem CreateLoopSystem() } } - private struct NetworkEarlyUpdate + internal struct NetworkEarlyUpdate { public static PlayerLoopSystem CreateLoopSystem() { @@ -174,7 +174,7 @@ public static PlayerLoopSystem CreateLoopSystem() } } - private struct NetworkFixedUpdate + internal struct NetworkFixedUpdate { public static PlayerLoopSystem CreateLoopSystem() { @@ -186,7 +186,7 @@ public static PlayerLoopSystem CreateLoopSystem() } } - private struct NetworkPreUpdate + internal struct NetworkPreUpdate { public static PlayerLoopSystem CreateLoopSystem() { @@ -198,7 +198,7 @@ public static PlayerLoopSystem CreateLoopSystem() } } - private struct NetworkUpdate + internal struct NetworkUpdate { public static PlayerLoopSystem CreateLoopSystem() { @@ -210,7 +210,7 @@ public static PlayerLoopSystem CreateLoopSystem() } } - private struct NetworkPreLateUpdate + internal struct NetworkPreLateUpdate { public static PlayerLoopSystem CreateLoopSystem() { @@ -222,7 +222,7 @@ public static PlayerLoopSystem CreateLoopSystem() } } - private struct NetworkPostLateUpdate + internal struct NetworkPostLateUpdate { public static PlayerLoopSystem CreateLoopSystem() { @@ -361,4 +361,4 @@ private static void Initialize() PlayerLoop.SetPlayerLoop(customPlayerLoop); } } -} \ No newline at end of file +} diff --git a/com.unity.multiplayer.mlapi/Tests/Runtime/NetworkUpdateLoopTests.cs b/com.unity.multiplayer.mlapi/Tests/Runtime/NetworkUpdateLoopTests.cs index 47a6e67b11..7f9460d248 100644 --- a/com.unity.multiplayer.mlapi/Tests/Runtime/NetworkUpdateLoopTests.cs +++ b/com.unity.multiplayer.mlapi/Tests/Runtime/NetworkUpdateLoopTests.cs @@ -1,13 +1,70 @@ using System; using System.Collections; +using System.Linq; using UnityEngine; using UnityEngine.TestTools; using NUnit.Framework; +using UnityEngine.LowLevel; +using UnityEngine.PlayerLoop; namespace MLAPI.RuntimeTests { public class NetworkUpdateLoopTests { + [Test] + public void UpdateStageInjection() + { + var currentPlayerLoop = PlayerLoop.GetCurrentPlayerLoop(); + for (int i = 0; i < currentPlayerLoop.subSystemList.Length; i++) + { + var playerLoopSystem = currentPlayerLoop.subSystemList[i]; + var subsystems = playerLoopSystem.subSystemList.ToList(); + + if (playerLoopSystem.type == typeof(Initialization)) + { + Assert.True( + subsystems.Exists(s => s.type == typeof(NetworkUpdateLoop.NetworkInitialization)), + nameof(NetworkUpdateLoop.NetworkInitialization)); + } + else if (playerLoopSystem.type == typeof(EarlyUpdate)) + { + Assert.True( + subsystems.Exists(s => s.type == typeof(NetworkUpdateLoop.NetworkEarlyUpdate)), + nameof(NetworkUpdateLoop.NetworkEarlyUpdate)); + } + else if (playerLoopSystem.type == typeof(FixedUpdate)) + { + Assert.True( + subsystems.Exists(s => s.type == typeof(NetworkUpdateLoop.NetworkFixedUpdate)), + nameof(NetworkUpdateLoop.NetworkFixedUpdate)); + } + else if (playerLoopSystem.type == typeof(PreUpdate)) + { + Assert.True( + subsystems.Exists(s => s.type == typeof(NetworkUpdateLoop.NetworkPreUpdate)), + nameof(NetworkUpdateLoop.NetworkPreUpdate)); + } + else if (playerLoopSystem.type == typeof(Update)) + { + Assert.True( + subsystems.Exists(s => s.type == typeof(NetworkUpdateLoop.NetworkUpdate)), + nameof(NetworkUpdateLoop.NetworkUpdate)); + } + else if (playerLoopSystem.type == typeof(PreLateUpdate)) + { + Assert.True( + subsystems.Exists(s => s.type == typeof(NetworkUpdateLoop.NetworkPreLateUpdate)), + nameof(NetworkUpdateLoop.NetworkPreLateUpdate)); + } + else if (playerLoopSystem.type == typeof(PostLateUpdate)) + { + Assert.True( + subsystems.Exists(s => s.type == typeof(NetworkUpdateLoop.NetworkPostLateUpdate)), + nameof(NetworkUpdateLoop.NetworkPostLateUpdate)); + } + } + } + private struct NetworkUpdateCallbacks { public Action OnInitialization; @@ -292,4 +349,4 @@ public IEnumerator UpdateStagesMixed() } } } -} \ No newline at end of file +}