Skip to content
5 changes: 2 additions & 3 deletions com.unity.netcode.gameobjects/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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<T>, which adds support for client anticipation of NetworkVariable values, allowing for more responsive gameplay (#2820)
- Added AnticipatedNetworkVariable<T>, 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<T> with the callback NetworkVariable<T>.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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 = "";
Expand All @@ -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");

Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down Expand Up @@ -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";

Expand Down
2 changes: 1 addition & 1 deletion com.unity.netcode.gameobjects/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down