com.unity.netcode.gameobjects@2.0.0-pre.4
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). ## [2.0.0-pre.4] - 2024-08-21 ### 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. (#3004) ### Fixed - Fixed issue where nested `NetworkTransform` components were not getting updated. (#3016) - Fixed issue by adding null checks in `NetworkVariableBase.CanClientRead` and `NetworkVariableBase.CanClientWrite` methods to ensure safe access to `NetworkBehaviour`. (#3012) - 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. (#3009) - 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. (#3008) - Fixed issue using collections within `NetworkVariable` where the collection would not detect changes to items or nested items. (#3004) - Fixed issue where `List`, `Dictionary`, and `HashSet` collections would not uniquely duplicate nested collections. (#3004) - Fixed issue where `NotAuthorityTarget` would include the service observer in the list of targets to send the RPC to as opposed to excluding the service observer as it should. (#3000) - Fixed issue where `ProxyRpcTargetGroup` could attempt to send a message if there were no targets to send to. (#3000) ### Changed - Changed `NetworkAnimator` to automatically switch to owner authoritative mode when using a distributed authority network topology. (#3021) - Changed permissions exception thrown in `NetworkList` to exiting early with a logged error that is now a unified permissions message within `NetworkVariableBase`. (#3004) - Changed permissions exception thrown in `NetworkVariable.Value` to exiting early with a logged error that is now a unified permissions message within `NetworkVariableBase`. (#3004)
This commit is contained in:
@@ -40,11 +40,6 @@ namespace Unity.Netcode.RuntimeTests
|
||||
public NetworkList<int> MyNetworkList = new NetworkList<int>(new List<int> { 1, 2, 3 });
|
||||
public NetworkVariable<int> MyNetworkVar = new NetworkVariable<int>(3);
|
||||
|
||||
[Rpc(SendTo.NotAuthority)]
|
||||
public void TestNotAuthorityRpc(byte[] _)
|
||||
{
|
||||
}
|
||||
|
||||
[Rpc(SendTo.Authority)]
|
||||
public void TestAuthorityRpc(byte[] _)
|
||||
{
|
||||
@@ -263,15 +258,6 @@ namespace Unity.Netcode.RuntimeTests
|
||||
yield return m_ClientCodecHook.WaitForMessageReceived<NetworkVariableDeltaMessage>();
|
||||
}
|
||||
|
||||
[UnityTest]
|
||||
public IEnumerator NotAuthorityRpc()
|
||||
{
|
||||
Client.LocalClient.PlayerObject.GetComponent<TestNetworkComponent>().TestNotAuthorityRpc(new byte[] { 1, 2, 3, 4 });
|
||||
|
||||
// Universal Rpcs are sent as a ProxyMessage (which contains an RpcMessage)
|
||||
yield return m_ClientCodecHook.WaitForMessageReceived<ProxyMessage>();
|
||||
}
|
||||
|
||||
[UnityTest]
|
||||
public IEnumerator ParentSync()
|
||||
{
|
||||
|
||||
97
Tests/Runtime/DistributedAuthority/RpcProxyMessageTesting.cs
Normal file
97
Tests/Runtime/DistributedAuthority/RpcProxyMessageTesting.cs
Normal file
@@ -0,0 +1,97 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using NUnit.Framework;
|
||||
using Unity.Netcode.TestHelpers.Runtime;
|
||||
|
||||
namespace Unity.Netcode.RuntimeTests
|
||||
{
|
||||
/// <summary>
|
||||
/// This test validates PR-3000 where it would invoke
|
||||
/// TODO:
|
||||
/// We really need to get the service running during tests
|
||||
/// so we can validate these issues. While this test does
|
||||
/// partially validate it we still need to manually validate
|
||||
/// with a service connection.
|
||||
/// </summary>
|
||||
[TestFixture(HostOrServer.Host)]
|
||||
[TestFixture(HostOrServer.DAHost)]
|
||||
public class RpcProxyMessageTesting : NetcodeIntegrationTest
|
||||
{
|
||||
protected override int NumberOfClients => 2;
|
||||
|
||||
private List<RpcProxyText> m_ProxyTestInstances = new List<RpcProxyText>();
|
||||
|
||||
private StringBuilder m_ValidationLogger = new StringBuilder();
|
||||
|
||||
public RpcProxyMessageTesting(HostOrServer hostOrServer) : base(hostOrServer) { }
|
||||
|
||||
protected override IEnumerator OnSetup()
|
||||
{
|
||||
m_ProxyTestInstances.Clear();
|
||||
return base.OnSetup();
|
||||
}
|
||||
|
||||
protected override void OnCreatePlayerPrefab()
|
||||
{
|
||||
m_PlayerPrefab.AddComponent<RpcProxyText>();
|
||||
base.OnCreatePlayerPrefab();
|
||||
}
|
||||
|
||||
|
||||
private bool ValidateRpcProxyRpcs()
|
||||
{
|
||||
m_ValidationLogger.Clear();
|
||||
foreach (var proxy in m_ProxyTestInstances)
|
||||
{
|
||||
if (proxy.ReceivedRpc.Count < NumberOfClients)
|
||||
{
|
||||
m_ValidationLogger.AppendLine($"Not all clients received RPC from Client-{proxy.OwnerClientId}!");
|
||||
}
|
||||
foreach (var clientId in proxy.ReceivedRpc)
|
||||
{
|
||||
if (clientId == proxy.OwnerClientId)
|
||||
{
|
||||
m_ValidationLogger.AppendLine($"Client-{proxy.OwnerClientId} sent itself an Rpc!");
|
||||
}
|
||||
}
|
||||
}
|
||||
return m_ValidationLogger.Length == 0;
|
||||
}
|
||||
|
||||
|
||||
public IEnumerator ProxyDoesNotInvokeOnSender()
|
||||
{
|
||||
m_ProxyTestInstances.Add(m_ServerNetworkManager.LocalClient.PlayerObject.GetComponent<RpcProxyText>());
|
||||
foreach (var client in m_ClientNetworkManagers)
|
||||
{
|
||||
m_ProxyTestInstances.Add(client.LocalClient.PlayerObject.GetComponent<RpcProxyText>());
|
||||
}
|
||||
|
||||
foreach (var clientProxyTest in m_ProxyTestInstances)
|
||||
{
|
||||
clientProxyTest.SendToEveryOneButMe();
|
||||
}
|
||||
|
||||
yield return WaitForConditionOrTimeOut(ValidateRpcProxyRpcs);
|
||||
AssertOnTimeout(m_ValidationLogger.ToString());
|
||||
}
|
||||
|
||||
public class RpcProxyText : NetworkBehaviour
|
||||
{
|
||||
public List<ulong> ReceivedRpc = new List<ulong>();
|
||||
|
||||
public void SendToEveryOneButMe()
|
||||
{
|
||||
var baseTarget = NetworkManager.DistributedAuthorityMode ? RpcTarget.NotAuthority : RpcTarget.NotMe;
|
||||
TestRpc(baseTarget);
|
||||
}
|
||||
|
||||
[Rpc(SendTo.SpecifiedInParams)]
|
||||
private void TestRpc(RpcParams rpcParams = default)
|
||||
{
|
||||
ReceivedRpc.Add(rpcParams.Receive.SenderClientId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 22d1d751fe245f7419f8393090c27106
|
||||
Reference in New Issue
Block a user