The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). Additional documentation and release notes are available at [Multiplayer Documentation](https://docs-multiplayer.unity3d.com). ## [1.11.0] - 2024-08-20 ### Added - Added `NetworkVariable.CheckDirtyState` that is to be used in tandem with collections in order to detect whether the collection or an item within the collection has changed. (#3005) ### Fixed - Fixed issue by adding null checks in `NetworkVariableBase.CanClientRead` and `NetworkVariableBase.CanClientWrite` methods to ensure safe access to `NetworkBehaviour`. (#3011) - Fixed issue using collections within `NetworkVariable` where the collection would not detect changes to items or nested items. (#3005) - Fixed issue where `List`, `Dictionary`, and `HashSet` collections would not uniquely duplicate nested collections. (#3005) - Fixed Issue where a state with dual triggers, inbound and outbound, could cause a false layer to layer state transition message to be sent to non-authority `NetworkAnimator` instances and cause a warning message to be logged. (#2999) - Fixed issue where `FixedStringSerializer<T>` was using `NetworkVariableSerialization<byte>.AreEqual` to determine if two bytes were equal causes an exception to be thrown due to no byte serializer having been defined. (#2992) ### Changed - Changed permissions exception thrown in `NetworkList` to exiting early with a logged error that is now a unified permissions message within `NetworkVariableBase`. (#3005) - Changed permissions exception thrown in `NetworkVariable.Value` to exiting early with a logged error that is now a unified permissions message within `NetworkVariableBase`. (#3005)
This commit is contained in:
2994
Tests/Runtime/NetworkVariableCollectionsTests.cs
Normal file
2994
Tests/Runtime/NetworkVariableCollectionsTests.cs
Normal file
File diff suppressed because it is too large
Load Diff
11
Tests/Runtime/NetworkVariableCollectionsTests.cs.meta
Normal file
11
Tests/Runtime/NetworkVariableCollectionsTests.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 939ac41f36685f84e94a4b66ebbb6d8c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -254,7 +254,8 @@ namespace Unity.Netcode.RuntimeTests
|
||||
var oldValue = testCompClient.ServerWritable_Position.Value;
|
||||
var newValue = oldValue + new Vector3(Random.Range(0, 100.0f), Random.Range(0, 100.0f), Random.Range(0, 100.0f));
|
||||
|
||||
Assert.That(() => testCompClient.ServerWritable_Position.Value = newValue, Throws.TypeOf<InvalidOperationException>());
|
||||
LogAssert.Expect(LogType.Error, testCompClient.ServerWritable_Position.GetWritePermissionError());
|
||||
testCompClient.ServerWritable_Position.Value = newValue;
|
||||
yield return WaitForPositionsAreEqual(testCompServer.ServerWritable_Position, oldValue);
|
||||
|
||||
yield return WaitForServerWritableAreEqualOnAll();
|
||||
@@ -283,7 +284,8 @@ namespace Unity.Netcode.RuntimeTests
|
||||
var oldValue = testCompServer.OwnerWritable_Position.Value;
|
||||
var newValue = oldValue + new Vector3(Random.Range(0, 100.0f), Random.Range(0, 100.0f), Random.Range(0, 100.0f));
|
||||
|
||||
Assert.That(() => testCompServer.OwnerWritable_Position.Value = newValue, Throws.TypeOf<InvalidOperationException>());
|
||||
LogAssert.Expect(LogType.Error, testCompServer.OwnerWritable_Position.GetWritePermissionError());
|
||||
testCompServer.OwnerWritable_Position.Value = newValue;
|
||||
yield return WaitForPositionsAreEqual(testCompServer.OwnerWritable_Position, oldValue);
|
||||
|
||||
yield return WaitForOwnerWritableAreEqualOnAll();
|
||||
@@ -589,8 +591,8 @@ namespace Unity.Netcode.RuntimeTests
|
||||
{
|
||||
InitializeServerAndClients(useHost);
|
||||
|
||||
// client must not be allowed to write to a server auth variable
|
||||
Assert.Throws<InvalidOperationException>(() => m_Player1OnClient1.TheScalar.Value = k_TestVal1);
|
||||
LogAssert.Expect(LogType.Error, m_Player1OnClient1.TheScalar.GetWritePermissionError());
|
||||
m_Player1OnClient1.TheScalar.Value = k_TestVal1;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Unity.Netcode.TestHelpers.Runtime;
|
||||
@@ -130,72 +129,44 @@ namespace Unity.Netcode.RuntimeTests
|
||||
for (var clientWriting = 0; clientWriting < 3; clientWriting++)
|
||||
{
|
||||
// ==== Server-writable NetworkVariable ====
|
||||
var gotException = false;
|
||||
Debug.Log($"Writing to server-write variable on object {objectIndex} on client {clientWriting}");
|
||||
VerboseDebug($"Writing to server-write variable on object {objectIndex} on client {clientWriting}");
|
||||
|
||||
try
|
||||
nextValueToWrite++;
|
||||
if (clientWriting != serverIndex)
|
||||
{
|
||||
nextValueToWrite++;
|
||||
OwnerPermissionObject.Objects[objectIndex, clientWriting].MyNetworkVariableServer.Value = nextValueToWrite;
|
||||
LogAssert.Expect(LogType.Error, OwnerPermissionObject.Objects[objectIndex, clientWriting].MyNetworkVariableServer.GetWritePermissionError());
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
gotException = true;
|
||||
}
|
||||
|
||||
// Verify server-owned netvar can only be written by server
|
||||
Debug.Assert(gotException == (clientWriting != serverIndex));
|
||||
OwnerPermissionObject.Objects[objectIndex, clientWriting].MyNetworkVariableServer.Value = nextValueToWrite;
|
||||
|
||||
// ==== Owner-writable NetworkVariable ====
|
||||
gotException = false;
|
||||
Debug.Log($"Writing to owner-write variable on object {objectIndex} on client {clientWriting}");
|
||||
VerboseDebug($"Writing to owner-write variable on object {objectIndex} on client {clientWriting}");
|
||||
|
||||
try
|
||||
nextValueToWrite++;
|
||||
if (clientWriting != objectIndex)
|
||||
{
|
||||
nextValueToWrite++;
|
||||
OwnerPermissionObject.Objects[objectIndex, clientWriting].MyNetworkVariableOwner.Value = nextValueToWrite;
|
||||
LogAssert.Expect(LogType.Error, OwnerPermissionObject.Objects[objectIndex, clientWriting].MyNetworkVariableOwner.GetWritePermissionError());
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
gotException = true;
|
||||
}
|
||||
|
||||
// Verify client-owned netvar can only be written by owner
|
||||
Debug.Assert(gotException == (clientWriting != objectIndex));
|
||||
OwnerPermissionObject.Objects[objectIndex, clientWriting].MyNetworkVariableOwner.Value = nextValueToWrite;
|
||||
|
||||
// ==== Server-writable NetworkList ====
|
||||
gotException = false;
|
||||
Debug.Log($"Writing to server-write list on object {objectIndex} on client {clientWriting}");
|
||||
VerboseDebug($"Writing to [Add] server-write NetworkList on object {objectIndex} on client {clientWriting}");
|
||||
|
||||
try
|
||||
nextValueToWrite++;
|
||||
if (clientWriting != serverIndex)
|
||||
{
|
||||
nextValueToWrite++;
|
||||
OwnerPermissionObject.Objects[objectIndex, clientWriting].MyNetworkListServer.Add(nextValueToWrite);
|
||||
LogAssert.Expect(LogType.Error, OwnerPermissionObject.Objects[objectIndex, clientWriting].MyNetworkListServer.GetWritePermissionError());
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
gotException = true;
|
||||
}
|
||||
|
||||
// Verify server-owned networkList can only be written by server
|
||||
Debug.Assert(gotException == (clientWriting != serverIndex));
|
||||
OwnerPermissionObject.Objects[objectIndex, clientWriting].MyNetworkListServer.Add(nextValueToWrite);
|
||||
|
||||
// ==== Owner-writable NetworkList ====
|
||||
gotException = false;
|
||||
Debug.Log($"Writing to owner-write list on object {objectIndex} on client {clientWriting}");
|
||||
VerboseDebug($"Writing to [Add] owner-write NetworkList on object {objectIndex} on client {clientWriting}");
|
||||
|
||||
try
|
||||
nextValueToWrite++;
|
||||
if (clientWriting != objectIndex)
|
||||
{
|
||||
nextValueToWrite++;
|
||||
OwnerPermissionObject.Objects[objectIndex, clientWriting].MyNetworkListOwner.Add(nextValueToWrite);
|
||||
LogAssert.Expect(LogType.Error, OwnerPermissionObject.Objects[objectIndex, clientWriting].MyNetworkListOwner.GetWritePermissionError());
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
gotException = true;
|
||||
}
|
||||
|
||||
// Verify client-owned networkList can only be written by owner
|
||||
Debug.Assert(gotException == (clientWriting != objectIndex));
|
||||
OwnerPermissionObject.Objects[objectIndex, clientWriting].MyNetworkListOwner.Add(nextValueToWrite);
|
||||
|
||||
yield return WaitForTicks(m_ServerNetworkManager, 5);
|
||||
yield return WaitForTicks(m_ClientNetworkManagers[0], 5);
|
||||
|
||||
Reference in New Issue
Block a user