com.unity.netcode.gameobjects@1.0.0-pre.8
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.0.0-pre.8] - 2022-04-27 ### Changed - `unmanaged` structs are no longer universally accepted as RPC parameters because some structs (i.e., structs with pointers in them, such as `NativeList<T>`) can't be supported by the default memcpy struct serializer. Structs that are intended to be serialized across the network must add `INetworkSerializeByMemcpy` to the interface list (i.e., `struct Foo : INetworkSerializeByMemcpy`). This interface is empty and just serves to mark the struct as compatible with memcpy serialization. For external structs you can't edit, you can pass them to RPCs by wrapping them in `ForceNetworkSerializeByMemcpy<T>`. (#1901) ### Removed - Removed `SIPTransport` (#1870) - Removed `ClientNetworkTransform` from the package samples and moved to Boss Room's Utilities package which can be found [here](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/main/Packages/com.unity.multiplayer.samples.coop/Utilities/Net/ClientAuthority/ClientNetworkTransform.cs). ### Fixed - Fixed `NetworkTransform` generating false positive rotation delta checks when rolling over between 0 and 360 degrees. (#1890) - Fixed client throwing an exception if it has messages in the outbound queue when processing the `NetworkEvent.Disconnect` event and is using UTP. (#1884) - Fixed issue during client synchronization if 'ValidateSceneBeforeLoading' returned false it would halt the client synchronization process resulting in a client that was approved but not synchronized or fully connected with the server. (#1883) - Fixed an issue where UNetTransport.StartServer would return success even if the underlying transport failed to start (#854) - Passing generic types to RPCs no longer causes a native crash (#1901) - Fixed an issue where calling `Shutdown` on a `NetworkManager` that was already shut down would cause an immediate shutdown the next time it was started (basically the fix makes `Shutdown` idempotent). (#1877)
This commit is contained in:
@@ -4,6 +4,7 @@ using System.Collections.Generic;
|
||||
using NUnit.Framework;
|
||||
using UnityEngine.TestTools;
|
||||
using Unity.Netcode.TestHelpers.Runtime;
|
||||
using UnityEngine;
|
||||
using Debug = UnityEngine.Debug;
|
||||
|
||||
namespace Unity.Netcode.RuntimeTests
|
||||
@@ -13,6 +14,7 @@ namespace Unity.Netcode.RuntimeTests
|
||||
public class RpcTestNB : NetworkBehaviour
|
||||
{
|
||||
public event Action<ulong, ServerRpcParams> OnServer_Rpc;
|
||||
public event Action<Vector3, Vector3[]> OnTypedServer_Rpc;
|
||||
public event Action OnClient_Rpc;
|
||||
|
||||
[ServerRpc]
|
||||
@@ -26,6 +28,12 @@ namespace Unity.Netcode.RuntimeTests
|
||||
{
|
||||
OnClient_Rpc();
|
||||
}
|
||||
|
||||
[ServerRpc]
|
||||
public void MyTypedServerRpc(Vector3 param1, Vector3[] param2)
|
||||
{
|
||||
OnTypedServer_Rpc(param1, param2);
|
||||
}
|
||||
}
|
||||
|
||||
protected override int NumberOfClients => 1;
|
||||
@@ -46,9 +54,13 @@ namespace Unity.Netcode.RuntimeTests
|
||||
|
||||
// Setup state
|
||||
bool hasReceivedServerRpc = false;
|
||||
bool hasReceivedTypedServerRpc = false;
|
||||
bool hasReceivedClientRpcRemotely = false;
|
||||
bool hasReceivedClientRpcLocally = false;
|
||||
|
||||
var vector3 = new Vector3(1, 2, 3);
|
||||
Vector3[] vector3s = new[] { new Vector3(4, 5, 6), new Vector3(7, 8, 9) };
|
||||
|
||||
localClienRpcTestNB.OnClient_Rpc += () =>
|
||||
{
|
||||
Debug.Log("ClientRpc received on client object");
|
||||
@@ -75,9 +87,22 @@ namespace Unity.Netcode.RuntimeTests
|
||||
hasReceivedClientRpcLocally = true;
|
||||
};
|
||||
|
||||
serverClientRpcTestNB.OnTypedServer_Rpc += (param1, param2) =>
|
||||
{
|
||||
Debug.Log("TypedServerRpc received on server object");
|
||||
Assert.AreEqual(param1, vector3);
|
||||
Assert.AreEqual(param2.Length, vector3s.Length);
|
||||
Assert.AreEqual(param2[0], vector3s[0]);
|
||||
Assert.AreEqual(param2[1], vector3s[1]);
|
||||
hasReceivedTypedServerRpc = true;
|
||||
};
|
||||
|
||||
// Send ServerRpc
|
||||
localClienRpcTestNB.MyServerRpc(m_ClientNetworkManagers[0].LocalClientId);
|
||||
|
||||
// Send TypedServerRpc
|
||||
localClienRpcTestNB.MyTypedServerRpc(vector3, vector3s);
|
||||
|
||||
// Send ClientRpc
|
||||
serverClientRpcTestNB.MyClientRpc();
|
||||
|
||||
@@ -86,6 +111,11 @@ namespace Unity.Netcode.RuntimeTests
|
||||
var serverMessageHookEntry = new MessageHookEntry(m_ServerNetworkManager);
|
||||
serverMessageHookEntry.AssignMessageType<ServerRpcMessage>();
|
||||
messageHookList.Add(serverMessageHookEntry);
|
||||
|
||||
var typedServerMessageHookEntry = new MessageHookEntry(m_ServerNetworkManager);
|
||||
typedServerMessageHookEntry.AssignMessageType<ServerRpcMessage>();
|
||||
messageHookList.Add(typedServerMessageHookEntry);
|
||||
|
||||
foreach (var client in m_ClientNetworkManagers)
|
||||
{
|
||||
var clientMessageHookEntry = new MessageHookEntry(client);
|
||||
@@ -97,9 +127,10 @@ namespace Unity.Netcode.RuntimeTests
|
||||
Assert.False(s_GlobalTimeoutHelper.TimedOut, $"Timed out waiting for messages: {rpcMessageHooks.GetHooksStillWaiting()}");
|
||||
|
||||
// Make sure RPCs propagated all the way up and were called on the relative destination class instance
|
||||
yield return WaitForConditionOrTimeOut(() => hasReceivedServerRpc && hasReceivedClientRpcLocally && hasReceivedClientRpcRemotely);
|
||||
yield return WaitForConditionOrTimeOut(() => hasReceivedServerRpc && hasReceivedClientRpcLocally && hasReceivedClientRpcRemotely && hasReceivedTypedServerRpc);
|
||||
|
||||
Assert.True(hasReceivedServerRpc, "ServerRpc was not received");
|
||||
Assert.True(hasReceivedTypedServerRpc, "TypedServerRpc was not received");
|
||||
Assert.True(hasReceivedClientRpcLocally, "ClientRpc was not locally received on the server");
|
||||
Assert.True(hasReceivedClientRpcRemotely, "ClientRpc was not remotely received on the client");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user