com.unity.netcode.gameobjects@1.3.1

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.3.1] - 2023-03-27

### Added

- Added detection and graceful handling of corrupt packets for additional safety. (#2419)

### Changed

- The UTP component UI has been updated to be more user-friendly for new users by adding a simple toggle to switch between local-only (127.0.0.1) and remote (0.0.0.0) binding modes, using the toggle "Allow Remote Connections" (#2408)
- Updated `UnityTransport` dependency on `com.unity.transport` to 1.3.3. (#2450)
- `NetworkShow()` of `NetworkObject`s are delayed until the end of the frame to ensure consistency of delta-driven variables like `NetworkList`.
- Dirty `NetworkObject` are reset at end-of-frame and not at serialization time.
- `NetworkHide()` of an object that was just `NetworkShow()`n produces a warning, as remote clients will _not_ get a spawn/despawn pair.
- Renamed the NetworkTransform.SetState parameter `shouldGhostsInterpolate` to `teleportDisabled` for better clarity of what that parameter does. (#2228)
- Network prefabs are now stored in a ScriptableObject that can be shared between NetworkManagers, and have been exposed for public access. By default, a Default Prefabs List is created that contains all NetworkObject prefabs in the project, and new NetworkManagers will default to using that unless that option is turned off in the Netcode for GameObjects settings. Existing NetworkManagers will maintain their existing lists, which can be migrated to the new format via a button in their inspector. (#2322)

### Fixed

- Fixed issue where changes to a layer's weight would not synchronize unless a state transition was occurring.(#2399)
- Fixed issue where `NetworkManager.LocalClientId` was returning the `NetworkTransport.ServerClientId` as opposed to the `NetworkManager.m_LocalClientId`. (#2398)
- Fixed issue where a dynamically spawned `NetworkObject` parented under an in-scene placed `NetworkObject` would have its `InScenePlaced` value changed to `true`. This would result in a soft synchronization error for late joining clients. (#2396)
- Fixed a UTP test that was failing when you install Unity Transport package 2.0.0 or newer. (#2347)
- Fixed issue where `NetcodeSettingsProvider` would throw an exception in Unity 2020.3.x versions. (#2345)
- Fixed server side issue where, depending upon component ordering, some NetworkBehaviour components might not have their OnNetworkDespawn method invoked if the client side disconnected. (#2323)
- Fixed a case where data corruption could occur when using UnityTransport when reaching a certain level of send throughput. (#2332)
- Fixed an issue in `UnityTransport` where an exception would be thrown if starting a Relay host/server on WebGL. This exception should only be thrown if using direct connections (where WebGL can't act as a host/server). (#2321)
- Fixed `NetworkAnimator` issue where it was not checking for `AnimatorStateTtansition.destinationStateMachine` and any possible sub-states defined within it. (#2309)
- Fixed `NetworkAnimator` issue where the host client was receiving the ClientRpc animation updates when the host was the owner.(#2309)
- Fixed `NetworkAnimator` issue with using pooled objects and when specific properties are cleaned during despawn and destroy.(#2309)
- Fixed issue where `NetworkAnimator` was checking for animation changes when the associated `NetworkObject` was not spawned.(#2309)
- Corrected an issue with the documentation for BufferSerializer (#2401)
This commit is contained in:
Unity Technologies
2023-03-27 00:00:00 +00:00
parent fe02ca682e
commit 8060718e04
69 changed files with 3128 additions and 888 deletions

View File

@@ -226,7 +226,7 @@ namespace Unity.Netcode.Transports.UTP
{
writer.WriteInt(messageLength);
var messageOffset = HeadIndex + reader.GetBytesRead();
var messageOffset = reader.GetBytesRead();
WriteBytes(ref writer, (byte*)m_Data.GetUnsafePtr() + messageOffset, messageLength);
writerAvailable -= sizeof(int) + messageLength;

View File

@@ -145,7 +145,7 @@ namespace Unity.Netcode.Transports.UTP
// Maximum reliable throughput, assuming the full reliable window can be sent on every
// frame at 60 FPS. This will be a large over-estimation in any realistic scenario.
private const int k_MaxReliableThroughput = (NetworkParameterConstants.MTU * 32 * 60) / 1000; // bytes per millisecond
private const int k_MaxReliableThroughput = (NetworkParameterConstants.MTU * 64 * 60) / 1000; // bytes per millisecond
private static ConnectionAddressData s_DefaultConnectionAddressData = new ConnectionAddressData { Address = "127.0.0.1", Port = 7777, ServerListenAddress = string.Empty };
@@ -303,20 +303,23 @@ namespace Unity.Netcode.Transports.UTP
public ushort Port;
/// <summary>
/// IP address the server will listen on. If not provided, will use 'Address'.
/// IP address the server will listen on. If not provided, will use localhost.
/// </summary>
[Tooltip("IP address the server will listen on. If not provided, will use 'Address'.")]
[Tooltip("IP address the server will listen on. If not provided, will use localhost.")]
[SerializeField]
public string ServerListenAddress;
private static NetworkEndpoint ParseNetworkEndpoint(string ip, ushort port)
private static NetworkEndpoint ParseNetworkEndpoint(string ip, ushort port, bool silent = false)
{
NetworkEndpoint endpoint = default;
if (!NetworkEndpoint.TryParse(ip, port, out endpoint, NetworkFamily.Ipv4) &&
!NetworkEndpoint.TryParse(ip, port, out endpoint, NetworkFamily.Ipv6))
{
Debug.LogError($"Invalid network endpoint: {ip}:{port}.");
if (!silent)
{
Debug.LogError($"Invalid network endpoint: {ip}:{port}.");
}
}
return endpoint;
@@ -330,9 +333,34 @@ namespace Unity.Netcode.Transports.UTP
/// <summary>
/// Endpoint (IP address and port) server will listen/bind on.
/// </summary>
public NetworkEndpoint ListenEndPoint => ParseNetworkEndpoint((ServerListenAddress?.Length == 0) ? Address : ServerListenAddress, Port);
public NetworkEndpoint ListenEndPoint
{
get
{
if (string.IsNullOrEmpty(ServerListenAddress))
{
var ep = NetworkEndpoint.LoopbackIpv4;
// If an address was entered and it's IPv6, switch to using ::1 as the
// default listen address. (Otherwise we always assume IPv4.)
if (!string.IsNullOrEmpty(Address) && ServerEndPoint.Family == NetworkFamily.Ipv6)
{
ep = NetworkEndpoint.LoopbackIpv6;
}
return ep.WithPort(Port);
}
else
{
return ParseNetworkEndpoint(ServerListenAddress, Port);
}
}
}
public bool IsIpv6 => !string.IsNullOrEmpty(Address) && ParseNetworkEndpoint(Address, Port, true).Family == NetworkFamily.Ipv6;
}
/// <summary>
/// The connection (address) data for this <see cref="UnityTransport"/> instance.
/// This is where you can change IP Address, Port, or server's listen address.
@@ -529,14 +557,14 @@ namespace Unity.Netcode.Transports.UTP
int result = m_Driver.Bind(endPoint);
if (result != 0)
{
Debug.LogError("Server failed to bind");
Debug.LogError("Server failed to bind. This is usually caused by another process being bound to the same port.");
return false;
}
result = m_Driver.Listen();
if (result != 0)
{
Debug.LogError("Server failed to listen");
Debug.LogError("Server failed to listen.");
return false;
}
@@ -609,7 +637,7 @@ namespace Unity.Netcode.Transports.UTP
{
Address = ipv4Address,
Port = port,
ServerListenAddress = listenAddress ?? string.Empty
ServerListenAddress = listenAddress ?? ipv4Address
};
SetProtocol(ProtocolType.UnityTransport);
@@ -1153,17 +1181,20 @@ namespace Unity.Netcode.Transports.UTP
m_NetworkSettings = new NetworkSettings(Allocator.Persistent);
#if !UNITY_WEBGL
// If the user sends a message of exactly m_MaxPayloadSize in length, we need to
// account for the overhead of its length when we store it in the send queue.
var fragmentationCapacity = m_MaxPayloadSize + BatchedSendQueue.PerMessageOverhead;
m_NetworkSettings.WithFragmentationStageParameters(payloadCapacity: fragmentationCapacity);
#if !UTP_TRANSPORT_2_0_ABOVE
// Bump the reliable window size to its maximum size of 64. Since NGO makes heavy use of
// reliable delivery, we're better off with the increased window size compared to the
// extra 4 bytes of header that this costs us.
m_NetworkSettings.WithReliableStageParameters(windowSize: 64);
#if !UTP_TRANSPORT_2_0_ABOVE && !UNITY_WEBGL
m_NetworkSettings.WithBaselibNetworkInterfaceParameters(
receiveQueueCapacity: m_MaxPacketQueueSize,
sendQueueCapacity: m_MaxPacketQueueSize);
#endif
#endif
}
@@ -1449,7 +1480,7 @@ namespace Unity.Netcode.Transports.UTP
heartbeatTimeoutMS: transport.m_HeartbeatTimeoutMS);
#if UNITY_WEBGL && !UNITY_EDITOR
if (NetworkManager.IsServer)
if (NetworkManager.IsServer && m_ProtocolType != ProtocolType.RelayUnityTransport)
{
throw new Exception("WebGL as a server is not supported by Unity Transport, outside the Editor.");
}
@@ -1473,7 +1504,7 @@ namespace Unity.Netcode.Transports.UTP
{
if (NetworkManager.IsServer)
{
if (String.IsNullOrEmpty(m_ServerCertificate) || String.IsNullOrEmpty(m_ServerPrivateKey))
if (string.IsNullOrEmpty(m_ServerCertificate) || string.IsNullOrEmpty(m_ServerPrivateKey))
{
throw new Exception("In order to use encrypted communications, when hosting, you must set the server certificate and key.");
}
@@ -1482,11 +1513,11 @@ namespace Unity.Netcode.Transports.UTP
}
else
{
if (String.IsNullOrEmpty(m_ServerCommonName))
if (string.IsNullOrEmpty(m_ServerCommonName))
{
throw new Exception("In order to use encrypted communications, clients must set the server common name.");
}
else if (String.IsNullOrEmpty(m_ClientCaCertificate))
else if (string.IsNullOrEmpty(m_ClientCaCertificate))
{
m_NetworkSettings.WithSecureClientParameters(m_ServerCommonName);
}