com.unity.netcode.gameobjects@1.7.0
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.7.0] - 2023-10-11 ### Added - exposed NetworkObject.GetNetworkBehaviourAtOrderIndex as a public API (#2724) - Added context menu tool that provides users with the ability to quickly update the GlobalObjectIdHash value for all in-scene placed prefab instances that were created prior to adding a NetworkObject component to it. (#2707) - Added methods NetworkManager.SetPeerMTU and NetworkManager.GetPeerMTU to be able to set MTU sizes per-peer (#2676) - Added `GenerateSerializationForGenericParameterAttribute`, which can be applied to user-created Network Variable types to ensure the codegen generates serialization for the generic types they wrap. (#2694) - Added `GenerateSerializationForTypeAttribute`, which can be applied to any class or method to ensure the codegen generates serialization for the specific provided type. (#2694) - Exposed `NetworkVariableSerialization<T>.Read`, `NetworkVariableSerialization<T>.Write`, `NetworkVariableSerialization<T>.AreEqual`, and `NetworkVariableSerialization<T>.Duplicate` to further support the creation of user-created network variables by allowing users to access the generated serialization methods and serialize generic types efficiently without boxing. (#2694) - Added `NetworkVariableBase.MarkNetworkBehaviourDirty` so that user-created network variable types can mark their containing `NetworkBehaviour` to be processed by the update loop. (#2694) ### Fixed - Fixed issue where the server side `NetworkSceneManager` instance was not adding the currently active scene to its list of scenes loaded. (#2723) - Generic NetworkBehaviour types no longer result in compile errors or runtime errors (#2720) - Rpcs within Generic NetworkBehaviour types can now serialize parameters of the class's generic types (but may not have generic types of their own) (#2720) - Errors are no longer thrown when entering play mode with domain reload disabled (#2720) - NetworkSpawn is now correctly called each time when entering play mode with scene reload disabled (#2720) - NetworkVariables of non-integer types will no longer break the inspector (#2714) - NetworkVariables with NonSerializedAttribute will not appear in the inspector (#2714) - Fixed issue where `UnityTransport` would attempt to establish WebSocket connections even if using UDP/DTLS Relay allocations when the build target was WebGL. This only applied to working in the editor since UDP/DTLS can't work in the browser. (#2695) - Fixed issue where a `NetworkBehaviour` component's `OnNetworkDespawn` was not being invoked on the host-server side for an in-scene placed `NetworkObject` when a scene was unloaded (during a scene transition) and the `NetworkBehaviour` component was positioned/ordered before the `NetworkObject` component. (#2685) - Fixed issue where `SpawnWithObservers` was not being honored when `NetworkConfig.EnableSceneManagement` was disabled. (#2682) - Fixed issue where `NetworkAnimator` was not internally tracking changes to layer weights which prevented proper layer weight synchronization back to the original layer weight value. (#2674) - Fixed "writing past the end of the buffer" error when calling ResetDirty() on managed network variables that are larger than 256 bytes when serialized. (#2670) - Fixed issue where generation of the `DefaultNetworkPrefabs` asset was not enabled by default. (#2662) - Fixed issue where the `GlobalObjectIdHash` value could be updated but the asset not marked as dirty. (#2662) - Fixed issue where the `GlobalObjectIdHash` value of a (network) prefab asset could be assigned an incorrect value when editing the prefab in a temporary scene. (#2662) - Fixed issue where the `GlobalObjectIdHash` value generated after creating a (network) prefab from an object constructed within the scene would not be the correct final value in a stand alone build. (#2662) ### Changed - Updated dependency on `com.unity.transport` to version 1.4.0. (#2716)
This commit is contained in:
@@ -242,7 +242,7 @@ namespace Unity.Netcode.Transports.UTP
|
||||
/// Fill the given <see cref="DataStreamWriter"/> with as many bytes from the queue as
|
||||
/// possible, disregarding message boundaries.
|
||||
/// </summary>
|
||||
///<remarks>
|
||||
/// <remarks>
|
||||
/// This does NOT actually consume anything from the queue. That is, calling this method
|
||||
/// does not reduce the length of the queue. Callers are expected to call
|
||||
/// <see cref="Consume"/> with the value returned by this method afterwards if the data can
|
||||
@@ -252,15 +252,17 @@ namespace Unity.Netcode.Transports.UTP
|
||||
/// this could lead to reading messages from a corrupted queue.
|
||||
/// </remarks>
|
||||
/// <param name="writer">The <see cref="DataStreamWriter"/> to write to.</param>
|
||||
/// <param name="maxBytes">Max number of bytes to copy (0 means writer capacity).</param>
|
||||
/// <returns>How many bytes were written to the writer.</returns>
|
||||
public int FillWriterWithBytes(ref DataStreamWriter writer)
|
||||
public int FillWriterWithBytes(ref DataStreamWriter writer, int maxBytes = 0)
|
||||
{
|
||||
if (!IsCreated || Length == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
var copyLength = Math.Min(writer.Capacity, Length);
|
||||
var maxLength = maxBytes == 0 ? writer.Capacity : Math.Min(maxBytes, writer.Capacity);
|
||||
var copyLength = Math.Min(maxLength, Length);
|
||||
|
||||
unsafe
|
||||
{
|
||||
|
||||
@@ -727,6 +727,7 @@ namespace Unity.Netcode.Transports.UTP
|
||||
public SendTarget Target;
|
||||
public BatchedSendQueue Queue;
|
||||
public NetworkPipeline ReliablePipeline;
|
||||
public int MTU;
|
||||
|
||||
public void Execute()
|
||||
{
|
||||
@@ -749,7 +750,7 @@ namespace Unity.Netcode.Transports.UTP
|
||||
// in the stream (the send queue does that automatically) we are sure they'll be
|
||||
// reassembled properly at the other end. This allows us to lift the limit of ~44KB
|
||||
// on reliable payloads (because of the reliable window size).
|
||||
var written = pipeline == ReliablePipeline ? Queue.FillWriterWithBytes(ref writer) : Queue.FillWriterWithMessages(ref writer);
|
||||
var written = pipeline == ReliablePipeline ? Queue.FillWriterWithBytes(ref writer, MTU) : Queue.FillWriterWithMessages(ref writer);
|
||||
|
||||
result = Driver.EndSend(writer);
|
||||
if (result == written)
|
||||
@@ -783,12 +784,21 @@ namespace Unity.Netcode.Transports.UTP
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var mtu = 0;
|
||||
if (NetworkManager)
|
||||
{
|
||||
var ngoClientId = NetworkManager.ConnectionManager.TransportIdToClientId(sendTarget.ClientId);
|
||||
mtu = NetworkManager.GetPeerMTU(ngoClientId);
|
||||
}
|
||||
|
||||
new SendBatchedMessagesJob
|
||||
{
|
||||
Driver = m_Driver.ToConcurrent(),
|
||||
Target = sendTarget,
|
||||
Queue = queue,
|
||||
ReliablePipeline = m_ReliableSequencedPipeline
|
||||
ReliablePipeline = m_ReliableSequencedPipeline,
|
||||
MTU = mtu,
|
||||
}.Run();
|
||||
}
|
||||
|
||||
@@ -1560,6 +1570,21 @@ namespace Unity.Netcode.Transports.UTP
|
||||
}
|
||||
#endif
|
||||
|
||||
#if UTP_TRANSPORT_2_1_ABOVE
|
||||
if (m_ProtocolType == ProtocolType.RelayUnityTransport)
|
||||
{
|
||||
if (m_UseWebSockets && m_RelayServerData.IsWebSocket == 0)
|
||||
{
|
||||
Debug.LogError("Transport is configured to use WebSockets, but Relay server data isn't. Be sure to use \"wss\" as the connection type when creating the server data (instead of \"dtls\" or \"udp\").");
|
||||
}
|
||||
|
||||
if (!m_UseWebSockets && m_RelayServerData.IsWebSocket != 0)
|
||||
{
|
||||
Debug.LogError("Relay server data indicates usage of WebSockets, but \"Use WebSockets\" checkbox isn't checked under \"Unity Transport\" component.");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if UTP_TRANSPORT_2_0_ABOVE
|
||||
if (m_UseWebSockets)
|
||||
{
|
||||
@@ -1567,7 +1592,7 @@ namespace Unity.Netcode.Transports.UTP
|
||||
}
|
||||
else
|
||||
{
|
||||
#if UNITY_WEBGL
|
||||
#if UNITY_WEBGL && !UNITY_EDITOR
|
||||
Debug.LogWarning($"WebSockets were used even though they're not selected in NetworkManager. You should check {nameof(UseWebSockets)}', on the Unity Transport component, to silence this warning.");
|
||||
driver = NetworkDriver.Create(new WebSocketNetworkInterface(), m_NetworkSettings);
|
||||
#else
|
||||
|
||||
Reference in New Issue
Block a user