com.unity.netcode.gameobjects@2.0.0-pre.3
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.3] - 2024-07-23 ### Added - Added: `UnityTransport.GetNetworkDriver` and `UnityTransport.GetLocalEndpoint` methods to expose the driver and local endpoint being used. (#2978) ### Fixed - Fixed issue where deferred despawn was causing GC allocations when converting an `IEnumerable` to a list. (#2983) - Fixed issue where the realtime network stats monitor was not able to display RPC traffic in release builds due to those stats being only available in development builds or the editor. (#2979) - Fixed issue where `NetworkManager.ScenesLoaded` was not being updated if `PostSynchronizationSceneUnloading` was set and any loaded scenes not used during synchronization were unloaded. (#2971) - Fixed issue where `Rigidbody2d` under Unity 6000.0.11f1 has breaking changes where `velocity` is now `linearVelocity` and `isKinematic` is replaced by `bodyType`. (#2971) - Fixed issue where `NetworkSpawnManager.InstantiateAndSpawn` and `NetworkObject.InstantiateAndSpawn` were not honoring the ownerClientId parameter when using a client-server network topology. (#2968) - Fixed issue where internal delta serialization could not have a byte serializer defined when serializing deltas for other types. Added `[GenerateSerializationForType(typeof(byte))]` to both the `NetworkVariable` and `AnticipatedNetworkVariable` classes to assure a byte serializer is defined.(#2962) - Fixed issue when scene management was disabled and the session owner would still try to synchronize a late joining client. (#2962) - Fixed issue when using a distributed authority network topology where it would allow a session owner to spawn a `NetworkObject` prior to being approved. Now, an error message is logged and the `NetworkObject` will not be spawned prior to the client being approved. (#2962) - Fixed issue where attempting to spawn during `NetworkBehaviour.OnInSceneObjectsSpawned` and `NetworkBehaviour.OnNetworkSessionSynchronized` notifications would throw a collection modified exception. (#2962) ### Changed - Changed logic where clients can now set the `NetworkSceneManager` client synchronization mode when using a distributed authority network topology. (#2985)
This commit is contained in:
@@ -428,6 +428,31 @@ namespace Unity.Netcode.Transports.UTP
|
||||
|
||||
protected NetworkDriver m_Driver;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a reference to the <see cref="Networking.Transport.NetworkDriver"/>.
|
||||
/// </summary>
|
||||
/// <returns>ref <see cref="Networking.Transport.NetworkDriver"/></returns>
|
||||
public ref NetworkDriver GetNetworkDriver()
|
||||
{
|
||||
return ref m_Driver;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the local sytem's <see cref="NetworkEndpoint"/> that is assigned for the current network session.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// If the driver is not created it will return an invalid <see cref="NetworkEndpoint"/>.
|
||||
/// </remarks>
|
||||
/// <returns><see cref="NetworkEndpoint"/></returns>
|
||||
public NetworkEndpoint GetLocalEndpoint()
|
||||
{
|
||||
if (m_Driver.IsCreated)
|
||||
{
|
||||
return m_Driver.GetLocalEndpoint();
|
||||
}
|
||||
return new NetworkEndpoint();
|
||||
}
|
||||
|
||||
private PacketLossCache m_PacketLossCache = new PacketLossCache();
|
||||
|
||||
private State m_State = State.Disconnected;
|
||||
@@ -450,7 +475,10 @@ namespace Unity.Netcode.Transports.UTP
|
||||
|
||||
private RelayServerData m_RelayServerData;
|
||||
|
||||
internal NetworkManager NetworkManager;
|
||||
/// <summary>
|
||||
/// NetworkManager associated to this transport instance
|
||||
/// </summary>
|
||||
protected NetworkManager m_NetworkManager;
|
||||
|
||||
private IRealTimeProvider m_RealTimeProvider;
|
||||
|
||||
@@ -795,10 +823,10 @@ namespace Unity.Netcode.Transports.UTP
|
||||
}
|
||||
|
||||
var mtu = 0;
|
||||
if (NetworkManager)
|
||||
if (m_NetworkManager)
|
||||
{
|
||||
var ngoClientId = NetworkManager.ConnectionManager.TransportIdToClientId(sendTarget.ClientId);
|
||||
mtu = NetworkManager.GetPeerMTU(ngoClientId);
|
||||
var ngoClientId = m_NetworkManager.ConnectionManager.TransportIdToClientId(sendTarget.ClientId);
|
||||
mtu = m_NetworkManager.GetPeerMTU(ngoClientId);
|
||||
}
|
||||
|
||||
new SendBatchedMessagesJob
|
||||
@@ -947,7 +975,7 @@ namespace Unity.Netcode.Transports.UTP
|
||||
}
|
||||
|
||||
#if MULTIPLAYER_TOOLS_1_0_0_PRE_7
|
||||
if (NetworkManager)
|
||||
if (m_NetworkManager)
|
||||
{
|
||||
ExtractNetworkMetrics();
|
||||
}
|
||||
@@ -963,16 +991,16 @@ namespace Unity.Netcode.Transports.UTP
|
||||
#if MULTIPLAYER_TOOLS_1_0_0_PRE_7
|
||||
private void ExtractNetworkMetrics()
|
||||
{
|
||||
if (NetworkManager.IsServer)
|
||||
if (m_NetworkManager.IsServer)
|
||||
{
|
||||
var ngoConnectionIds = NetworkManager.ConnectedClients.Keys;
|
||||
var ngoConnectionIds = m_NetworkManager.ConnectedClients.Keys;
|
||||
foreach (var ngoConnectionId in ngoConnectionIds)
|
||||
{
|
||||
if (ngoConnectionId == 0 && NetworkManager.IsHost)
|
||||
if (ngoConnectionId == 0 && m_NetworkManager.IsHost)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
var transportClientId = NetworkManager.ConnectionManager.ClientIdToTransportId(ngoConnectionId);
|
||||
var transportClientId = m_NetworkManager.ConnectionManager.ClientIdToTransportId(ngoConnectionId);
|
||||
ExtractNetworkMetricsForClient(transportClientId);
|
||||
}
|
||||
}
|
||||
@@ -992,10 +1020,10 @@ namespace Unity.Netcode.Transports.UTP
|
||||
ExtractNetworkMetricsFromPipeline(m_UnreliableSequencedFragmentedPipeline, networkConnection);
|
||||
ExtractNetworkMetricsFromPipeline(m_ReliableSequencedPipeline, networkConnection);
|
||||
|
||||
var rttValue = NetworkManager.IsServer ? 0 : ExtractRtt(networkConnection);
|
||||
var rttValue = m_NetworkManager.IsServer ? 0 : ExtractRtt(networkConnection);
|
||||
NetworkMetrics.UpdateRttToServer(rttValue);
|
||||
|
||||
var packetLoss = NetworkManager.IsServer ? 0 : ExtractPacketLoss(networkConnection);
|
||||
var packetLoss = m_NetworkManager.IsServer ? 0 : ExtractPacketLoss(networkConnection);
|
||||
NetworkMetrics.UpdatePacketLoss(packetLoss);
|
||||
}
|
||||
|
||||
@@ -1199,9 +1227,9 @@ namespace Unity.Netcode.Transports.UTP
|
||||
// use the transport client ID) or from a user (which will be using the NGO client ID).
|
||||
// So we just try both cases (ExtractRtt returns 0 for invalid connections).
|
||||
|
||||
if (NetworkManager != null)
|
||||
if (m_NetworkManager != null)
|
||||
{
|
||||
var transportId = NetworkManager.ConnectionManager.ClientIdToTransportId(clientId);
|
||||
var transportId = m_NetworkManager.ConnectionManager.ClientIdToTransportId(clientId);
|
||||
|
||||
var rtt = ExtractRtt(ParseClientId(transportId));
|
||||
if (rtt > 0)
|
||||
@@ -1221,14 +1249,14 @@ namespace Unity.Netcode.Transports.UTP
|
||||
{
|
||||
Debug.Assert(sizeof(ulong) == UnsafeUtility.SizeOf<NetworkConnection>(), "Netcode connection id size does not match UTP connection id size");
|
||||
|
||||
NetworkManager = networkManager;
|
||||
m_NetworkManager = networkManager;
|
||||
|
||||
if (NetworkManager && NetworkManager.PortOverride.Overidden)
|
||||
if (m_NetworkManager && m_NetworkManager.PortOverride.Overidden)
|
||||
{
|
||||
ConnectionData.Port = NetworkManager.PortOverride.Value;
|
||||
ConnectionData.Port = m_NetworkManager.PortOverride.Value;
|
||||
}
|
||||
|
||||
m_RealTimeProvider = NetworkManager ? NetworkManager.RealTimeProvider : new RealTimeProvider();
|
||||
m_RealTimeProvider = m_NetworkManager ? m_NetworkManager.RealTimeProvider : new RealTimeProvider();
|
||||
|
||||
m_NetworkSettings = new NetworkSettings(Allocator.Persistent);
|
||||
|
||||
@@ -1322,7 +1350,7 @@ namespace Unity.Netcode.Transports.UTP
|
||||
// provide any reliability guarantees anymore. Disconnect the client since at
|
||||
// this point they're bound to become desynchronized.
|
||||
|
||||
var ngoClientId = NetworkManager?.ConnectionManager.TransportIdToClientId(clientId) ?? clientId;
|
||||
var ngoClientId = m_NetworkManager?.ConnectionManager.TransportIdToClientId(clientId) ?? clientId;
|
||||
Debug.LogError($"Couldn't add payload of size {payload.Count} to reliable send queue. " +
|
||||
$"Closing connection {ngoClientId} as reliability guarantees can't be maintained.");
|
||||
|
||||
@@ -1479,7 +1507,7 @@ namespace Unity.Netcode.Transports.UTP
|
||||
|
||||
protected override NetworkTopologyTypes OnCurrentTopology()
|
||||
{
|
||||
return NetworkManager != null ? NetworkManager.NetworkConfig.NetworkTopology : NetworkTopologyTypes.ClientServer;
|
||||
return m_NetworkManager != null ? m_NetworkManager.NetworkConfig.NetworkTopology : NetworkTopologyTypes.ClientServer;
|
||||
}
|
||||
|
||||
private string m_ServerPrivateKey;
|
||||
@@ -1555,7 +1583,7 @@ namespace Unity.Netcode.Transports.UTP
|
||||
heartbeatTimeoutMS: transport.m_HeartbeatTimeoutMS);
|
||||
|
||||
#if UNITY_WEBGL && !UNITY_EDITOR
|
||||
if (NetworkManager.IsServer && m_ProtocolType != ProtocolType.RelayUnityTransport)
|
||||
if (m_NetworkManager.IsServer && m_ProtocolType != ProtocolType.RelayUnityTransport)
|
||||
{
|
||||
throw new Exception("WebGL as a server is not supported by Unity Transport, outside the Editor.");
|
||||
}
|
||||
@@ -1577,7 +1605,7 @@ namespace Unity.Netcode.Transports.UTP
|
||||
}
|
||||
else
|
||||
{
|
||||
if (NetworkManager.IsServer)
|
||||
if (m_NetworkManager.IsServer)
|
||||
{
|
||||
if (string.IsNullOrEmpty(m_ServerCertificate) || string.IsNullOrEmpty(m_ServerPrivateKey))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user