diff --git a/com.unity.netcode.gameobjects/CHANGELOG.md b/com.unity.netcode.gameobjects/CHANGELOG.md
index 05c29c03d7..48c00b5624 100644
--- a/com.unity.netcode.gameobjects/CHANGELOG.md
+++ b/com.unity.netcode.gameobjects/CHANGELOG.md
@@ -9,6 +9,8 @@ Additional documentation and release notes are available at [Multiplayer Documen
### Changed
+- When using `UnityTransport`, _reliable_ payloads are now allowed to exceed the configured 'Max Payload Size'. Unreliable payloads remain bounded by this setting. (#2081)
+
### Fixed
- Fixed issue where NetworkAnimator was not removing its subscription from OnClientConnectedCallback when despawned during the shutdown sequence. (#2074)
diff --git a/com.unity.netcode.gameobjects/Runtime/Transports/UTP/UnityTransport.cs b/com.unity.netcode.gameobjects/Runtime/Transports/UTP/UnityTransport.cs
index ad2787fee5..3728280066 100644
--- a/com.unity.netcode.gameobjects/Runtime/Transports/UTP/UnityTransport.cs
+++ b/com.unity.netcode.gameobjects/Runtime/Transports/UTP/UnityTransport.cs
@@ -158,11 +158,11 @@ public int MaxPacketQueueSize
set => m_MaxPacketQueueSize = value;
}
- [Tooltip("The maximum size of a payload that can be handled by the transport.")]
+ [Tooltip("The maximum size of an unreliable payload that can be handled by the transport.")]
[SerializeField]
private int m_MaxPayloadSize = InitialMaxPayloadSize;
- /// The maximum size of a payload that can be handled by the transport.
+ /// The maximum size of an unreliable payload that can be handled by the transport.
public int MaxPayloadSize
{
get => m_MaxPayloadSize;
@@ -1148,14 +1148,14 @@ public override NetcodeNetworkEvent PollEvent(out ulong clientId, out ArraySegme
/// The delivery type (QoS) to send data with
public override void Send(ulong clientId, ArraySegment payload, NetworkDelivery networkDelivery)
{
- if (payload.Count > m_MaxPayloadSize)
+ var pipeline = SelectSendPipeline(networkDelivery);
+
+ if (pipeline != m_ReliableSequencedPipeline && payload.Count > m_MaxPayloadSize)
{
- Debug.LogError($"Payload of size {payload.Count} larger than configured 'Max Payload Size' ({m_MaxPayloadSize}).");
+ Debug.LogError($"Unreliable payload of size {payload.Count} larger than configured 'Max Payload Size' ({m_MaxPayloadSize}).");
return;
}
- var pipeline = SelectSendPipeline(networkDelivery);
-
var sendTarget = new SendTarget(clientId, pipeline);
if (!m_SendQueue.TryGetValue(sendTarget, out var queue))
{
diff --git a/com.unity.netcode.gameobjects/Tests/Runtime/Transports/UnityTransportTests.cs b/com.unity.netcode.gameobjects/Tests/Runtime/Transports/UnityTransportTests.cs
index 5dec849759..481366e216 100644
--- a/com.unity.netcode.gameobjects/Tests/Runtime/Transports/UnityTransportTests.cs
+++ b/com.unity.netcode.gameobjects/Tests/Runtime/Transports/UnityTransportTests.cs
@@ -457,5 +457,26 @@ public IEnumerator SendQueuesFlushedOnRemoteClientDisconnect([ValueSource("k_Del
yield return null;
}
+
+ [UnityTest]
+ public IEnumerator ReliablePayloadsCanBeLargerThanMaximum()
+ {
+ InitializeTransport(out m_Server, out m_ServerEvents);
+ InitializeTransport(out m_Client1, out m_Client1Events);
+
+ m_Server.StartServer();
+ m_Client1.StartClient();
+
+ yield return WaitForNetworkEvent(NetworkEvent.Connect, m_Client1Events);
+
+ var payloadSize = UnityTransport.InitialMaxPayloadSize + 1;
+ var data = new ArraySegment(new byte[payloadSize]);
+
+ m_Server.Send(m_Client1.ServerClientId, data, NetworkDelivery.Reliable);
+
+ yield return WaitForNetworkEvent(NetworkEvent.Data, m_Client1Events);
+
+ yield return null;
+ }
}
}