diff --git a/com.unity.netcode.gameobjects/CHANGELOG.md b/com.unity.netcode.gameobjects/CHANGELOG.md index 6ba2d17346..959be375d1 100644 --- a/com.unity.netcode.gameobjects/CHANGELOG.md +++ b/com.unity.netcode.gameobjects/CHANGELOG.md @@ -6,17 +6,16 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) Additional documentation and release notes are available at [Multiplayer Documentation](https://docs-multiplayer.unity3d.com). -## [Unreleased] +## [1.9.1] - 2024-04-18 ### Added --Added AnticipatedNetworkVariable, which adds support for client anticipation of NetworkVariable values, allowing for more responsive gameplay (#2820) +- Added AnticipatedNetworkVariable, which adds support for client anticipation of NetworkVariable values, allowing for more responsive gameplay (#2820) - Added AnticipatedNetworkTransform, which adds support for client anticipation of NetworkTransforms (#2820) - Added NetworkVariableBase.ExceedsDirtinessThreshold to allow network variables to throttle updates by only sending updates when the difference between the current and previous values exceeds a threshold. (This is exposed in NetworkVariable with the callback NetworkVariable.CheckExceedsDirtinessThreshold) (#2820) - Added NetworkVariableUpdateTraits, which add additional throttling support: MinSecondsBetweenUpdates will prevent the NetworkVariable from sending updates more often than the specified time period (even if it exceeds the dirtiness threshold), while MaxSecondsBetweenUpdates will force a dirty NetworkVariable to send an update after the specified time period even if it has not yet exceeded the dirtiness threshold. (#2820) - Added virtual method NetworkVariableBase.OnInitialize() which can be used by NetworkVariable subclasses to add initialization code (#2820) - Added virtual method NetworkVariableBase.Update(), which is called once per frame to support behaviors such as interpolation between an anticipated value and an authoritative one. (#2820) - Added NetworkTime.TickWithPartial, which represents the current tick as a double that includes the fractional/partial tick value. (#2820) -- Added NetworkTickSystem.AnticipationTick, which can be helpful with implementation of client anticipation. This value represents the tick the current local client was at at the beginning of the most recent network round trip, which enables it to correlate server update ticks with the client tick that may have triggered them. (#2820) - `NetworkVariable` now includes built-in support for `NativeHashSet`, `NativeHashMap`, `List`, `HashSet`, and `Dictionary` (#2813) - `NetworkVariable` now includes delta compression for collection values (`NativeList`, `NativeArray`, `NativeHashSet`, `NativeHashMap`, `List`, `HashSet`, `Dictionary`, and `FixedString` types) to save bandwidth by only sending the values that changed. (Note: For `NativeList`, `NativeArray`, and `List`, this algorithm works differently than that used in `NetworkList`. This algorithm will use less bandwidth for "set" and "add" operations, but `NetworkList` is more bandwidth-efficient if you are performing frequent "insert" operations.) (#2813) - `UserNetworkVariableSerialization` now has optional callbacks for `WriteDelta` and `ReadDelta`. If both are provided, they will be used for all serialization operations on NetworkVariables of that type except for the first one for each client. If either is missing, the existing `Write` and `Read` will always be used. (#2813) diff --git a/com.unity.netcode.gameobjects/Editor/NetworkManagerEditor.cs b/com.unity.netcode.gameobjects/Editor/NetworkManagerEditor.cs index 1713ba226a..75c5765669 100644 --- a/com.unity.netcode.gameobjects/Editor/NetworkManagerEditor.cs +++ b/com.unity.netcode.gameobjects/Editor/NetworkManagerEditor.cs @@ -222,7 +222,7 @@ private void DrawAllPropertyFields() private void DrawTransportField() { #if RELAY_INTEGRATION_AVAILABLE - var useRelay = EditorPrefs.GetBool(k_UseEasyRelayIntegrationKey, false); + var useRelay = EditorPrefs.GetBool(m_UseEasyRelayIntegrationKey, false); #else var useRelay = false; #endif @@ -257,7 +257,7 @@ private void DrawTransportField() } #if RELAY_INTEGRATION_AVAILABLE - private readonly string k_UseEasyRelayIntegrationKey = "NetworkManagerUI_UseRelay_" + Application.dataPath.GetHashCode(); + private readonly string m_UseEasyRelayIntegrationKey = "NetworkManagerUI_UseRelay_" + Application.dataPath.GetHashCode(); private string m_JoinCode = ""; private string m_StartConnectionError = null; private string m_Region = ""; @@ -272,7 +272,7 @@ private void ShowStartConnectionButtons() #if RELAY_INTEGRATION_AVAILABLE // use editor prefs to persist the setting when entering / leaving play mode / exiting Unity - var useRelay = EditorPrefs.GetBool(k_UseEasyRelayIntegrationKey, false); + var useRelay = EditorPrefs.GetBool(m_UseEasyRelayIntegrationKey, false); GUILayout.BeginHorizontal(); useRelay = GUILayout.Toggle(useRelay, "Try Relay in the Editor"); @@ -284,7 +284,7 @@ private void ShowStartConnectionButtons() } GUILayout.EndHorizontal(); - EditorPrefs.SetBool(k_UseEasyRelayIntegrationKey, useRelay); + EditorPrefs.SetBool(m_UseEasyRelayIntegrationKey, useRelay); if (useRelay && !Application.isPlaying && !CloudProjectSettings.projectBound) { EditorGUILayout.HelpBox("To use relay, you need to setup your project in the Project Settings in the Services section.", MessageType.Warning); diff --git a/com.unity.netcode.gameobjects/Tests/Editor/Messaging/MessageCorruptionTests.cs b/com.unity.netcode.gameobjects/Tests/Editor/Messaging/MessageCorruptionTests.cs index 96544ac4a3..b37454f233 100644 --- a/com.unity.netcode.gameobjects/Tests/Editor/Messaging/MessageCorruptionTests.cs +++ b/com.unity.netcode.gameobjects/Tests/Editor/Messaging/MessageCorruptionTests.cs @@ -90,11 +90,16 @@ public unsafe void Send(ulong clientId, NetworkDelivery delivery, FastBufferWrit break; } case TypeOfCorruption.CorruptBytes: - batchData.Seek(batchData.Length - 2); - var currentByte = batchData.GetUnsafePtr()[0]; - batchData.WriteByteSafe((byte)(currentByte == 0 ? 1 : 0)); - MessageQueue.Add(batchData.ToArray()); - break; + { + batchData.Seek(batchData.Length - 4); + for (int i = 0; i < 4; i++) + { + var currentByte = batchData.GetUnsafePtr()[i]; + batchData.WriteByteSafe((byte)(currentByte == 0 ? 1 : 0)); + MessageQueue.Add(batchData.ToArray()); + } + break; + } case TypeOfCorruption.Truncated: batchData.Truncate(batchData.Length - 1); MessageQueue.Add(batchData.ToArray()); diff --git a/com.unity.netcode.gameobjects/Tests/Runtime/UniversalRpcTests.cs b/com.unity.netcode.gameobjects/Tests/Runtime/UniversalRpcTests.cs index 6be13427e0..e157a3a212 100644 --- a/com.unity.netcode.gameobjects/Tests/Runtime/UniversalRpcTests.cs +++ b/com.unity.netcode.gameobjects/Tests/Runtime/UniversalRpcTests.cs @@ -1285,23 +1285,31 @@ public enum AllocationType List } + // Extending timeout since the added yield return causes this test to commonly timeout + [Timeout(600000)] [UnityTest] public IEnumerator TestSendingWithGroupOverride() { + var waitFor = new WaitForFixedUpdate(); foreach (var defaultSendTo in Enum.GetValues(typeof(SendTo))) { + m_EnableVerboseDebug = true; + VerboseDebug($"Processing: {defaultSendTo}"); + m_EnableVerboseDebug = false; + foreach (var recipient in RecipientGroups) { for (ulong objectOwner = 0u; objectOwner <= 2u; ++objectOwner) { for (ulong sender = 0u; sender <= 2u; ++sender) { + yield return waitFor; foreach (var allocationType in Enum.GetValues(typeof(AllocationType))) { - if (++YieldCheck % YieldCycleCount == 0) - { - yield return null; - } + //if (++YieldCheck % YieldCycleCount == 0) + //{ + // yield return null; + //} OnInlineSetup(); var sendMethodName = $"DefaultTo{defaultSendTo}AllowOverrideRpc"; @@ -1378,23 +1386,32 @@ public enum AllocationType List } + // Extending timeout since the added yield return causes this test to commonly timeout + [Timeout(600000)] [UnityTest] public IEnumerator TestSendingWithGroupNotOverride() { + var waitFor = new WaitForFixedUpdate(); foreach (var defaultSendTo in Enum.GetValues(typeof(SendTo))) { + m_EnableVerboseDebug = true; + VerboseDebug($"Processing: {defaultSendTo}"); + m_EnableVerboseDebug = false; foreach (var recipient in RecipientGroups) { for (ulong objectOwner = 0u; objectOwner <= 2u; ++objectOwner) { for (ulong sender = 0u; sender <= 2u; ++sender) { + yield return waitFor; + foreach (var allocationType in Enum.GetValues(typeof(AllocationType))) { - if (++YieldCheck % YieldCycleCount == 0) - { - yield return null; - } + //if (++YieldCheck % YieldCycleCount == 0) + //{ + // yield return waitFor; + //} + OnInlineSetup(); var sendMethodName = $"DefaultTo{defaultSendTo}AllowOverrideRpc"; diff --git a/com.unity.netcode.gameobjects/package.json b/com.unity.netcode.gameobjects/package.json index 5a0c239d66..1e171cbcf8 100644 --- a/com.unity.netcode.gameobjects/package.json +++ b/com.unity.netcode.gameobjects/package.json @@ -2,7 +2,7 @@ "name": "com.unity.netcode.gameobjects", "displayName": "Netcode for GameObjects", "description": "Netcode for GameObjects is a high-level netcode SDK that provides networking capabilities to GameObject/MonoBehaviour workflows within Unity and sits on top of underlying transport layer.", - "version": "1.9.0", + "version": "1.9.1", "unity": "2021.3", "dependencies": { "com.unity.nuget.mono-cecil": "1.10.1",