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:
@@ -1,6 +1,12 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
[assembly: InternalsVisibleTo("TestProject.EditorTests")]
|
||||
[assembly: InternalsVisibleTo("TestProject.RuntimeTests")]
|
||||
[assembly: InternalsVisibleTo("TestProject.ToolsIntegration.RuntimeTests")]
|
||||
#if UNITY_INCLUDE_TESTS
|
||||
[assembly: InternalsVisibleTo("Unity.Netcode.RuntimeTests")]
|
||||
[assembly: InternalsVisibleTo("TestProject.RuntimeTests")]
|
||||
#if UNITY_EDITOR
|
||||
[assembly: InternalsVisibleTo("TestProject.EditorTests")]
|
||||
#endif // UNITY_EDITOR
|
||||
#if MULTIPLAYER_TOOLS
|
||||
[assembly: InternalsVisibleTo("TestProject.ToolsIntegration.RuntimeTests")]
|
||||
#endif // MULTIPLAYER_TOOLS
|
||||
#endif // UNITY_INCLUDE_TESTS
|
||||
|
||||
@@ -241,11 +241,20 @@ namespace Unity.Netcode.TestHelpers.Runtime
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Invoked immediately after the player prefab GameObject is created
|
||||
/// prior to adding a NetworkObject component
|
||||
/// </summary>
|
||||
protected virtual void OnPlayerPrefabGameObjectCreated()
|
||||
{
|
||||
}
|
||||
|
||||
private void CreatePlayerPrefab()
|
||||
{
|
||||
VerboseDebug($"Entering {nameof(CreatePlayerPrefab)}");
|
||||
// Create playerPrefab
|
||||
m_PlayerPrefab = new GameObject("Player");
|
||||
OnPlayerPrefabGameObjectCreated();
|
||||
NetworkObject networkObject = m_PlayerPrefab.AddComponent<NetworkObject>();
|
||||
|
||||
// Make it a prefab
|
||||
@@ -692,6 +701,7 @@ namespace Unity.Netcode.TestHelpers.Runtime
|
||||
}
|
||||
|
||||
VerboseDebug($"Exiting {nameof(TearDown)}");
|
||||
LogWaitForMessages();
|
||||
NetcodeLogAssert.Dispose();
|
||||
}
|
||||
|
||||
@@ -920,18 +930,7 @@ namespace Unity.Netcode.TestHelpers.Runtime
|
||||
Assert.IsNotNull(m_ServerNetworkManager, prefabCreateAssertError);
|
||||
Assert.IsFalse(m_ServerNetworkManager.IsListening, prefabCreateAssertError);
|
||||
|
||||
var gameObject = new GameObject();
|
||||
gameObject.name = baseName;
|
||||
var networkObject = gameObject.AddComponent<NetworkObject>();
|
||||
networkObject.NetworkManagerOwner = m_ServerNetworkManager;
|
||||
NetcodeIntegrationTestHelpers.MakeNetworkObjectTestPrefab(networkObject);
|
||||
var networkPrefab = new NetworkPrefab() { Prefab = gameObject };
|
||||
m_ServerNetworkManager.NetworkConfig.NetworkPrefabs.Add(networkPrefab);
|
||||
foreach (var clientNetworkManager in m_ClientNetworkManagers)
|
||||
{
|
||||
clientNetworkManager.NetworkConfig.NetworkPrefabs.Add(networkPrefab);
|
||||
}
|
||||
return gameObject;
|
||||
return NetcodeIntegrationTestHelpers.CreateNetworkObjectPrefab(baseName, m_ServerNetworkManager, m_ClientNetworkManagers);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1059,5 +1058,61 @@ namespace Unity.Netcode.TestHelpers.Runtime
|
||||
var asyncOperation = SceneManager.UnloadSceneAsync(scene);
|
||||
}
|
||||
}
|
||||
|
||||
private System.Text.StringBuilder m_WaitForLog = new System.Text.StringBuilder();
|
||||
|
||||
private void LogWaitForMessages()
|
||||
{
|
||||
VerboseDebug(m_WaitForLog.ToString());
|
||||
m_WaitForLog.Clear();
|
||||
}
|
||||
|
||||
private IEnumerator WaitForTickAndFrames(NetworkManager networkManager, int tickCount, float targetFrames)
|
||||
{
|
||||
var tickAndFramesConditionMet = false;
|
||||
var frameCount = 0;
|
||||
var waitForFixedUpdate = new WaitForFixedUpdate();
|
||||
m_WaitForLog.Append($"[NetworkManager-{networkManager.LocalClientId}][WaitForTicks-Begin] Waiting for ({tickCount}) network ticks and ({targetFrames}) frames to pass.\n");
|
||||
var tickStart = networkManager.NetworkTickSystem.LocalTime.Tick;
|
||||
while (!tickAndFramesConditionMet)
|
||||
{
|
||||
// Wait until both tick and frame counts have reached their targeted values
|
||||
if ((networkManager.NetworkTickSystem.LocalTime.Tick - tickStart) >= tickCount && frameCount >= targetFrames)
|
||||
{
|
||||
tickAndFramesConditionMet = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
yield return waitForFixedUpdate;
|
||||
frameCount++;
|
||||
// In the event something is broken with time systems (or the like)
|
||||
// Exit if we have exceeded 1000 frames
|
||||
if (frameCount >= 1000.0f)
|
||||
{
|
||||
tickAndFramesConditionMet = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
m_WaitForLog.Append($"[NetworkManager-{networkManager.LocalClientId}][WaitForTicks-End] Waited for ({networkManager.NetworkTickSystem.LocalTime.Tick - tickStart}) network ticks and ({frameCount}) frames to pass.\n");
|
||||
yield break;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Yields until specified amount of network ticks and the expected number of frames has been passed.
|
||||
/// </summary>
|
||||
protected IEnumerator WaitForTicks(NetworkManager networkManager, int count)
|
||||
{
|
||||
var targetTick = networkManager.NetworkTickSystem.LocalTime.Tick + count;
|
||||
|
||||
// Calculate the expected number of frame updates that should occur during the tick count wait period
|
||||
var frameFrequency = 1.0f / (Application.targetFrameRate >= 60 && Application.targetFrameRate <= 100 ? Application.targetFrameRate : 60.0f);
|
||||
var tickFrequency = 1.0f / networkManager.NetworkConfig.TickRate;
|
||||
var framesPerTick = tickFrequency / frameFrequency;
|
||||
|
||||
// Total number of frames to occur over the specified number of ticks
|
||||
var totalFrameCount = framesPerTick * count;
|
||||
m_WaitForLog.Append($"[NetworkManager-{networkManager.LocalClientId}][WaitForTicks] TickRate ({networkManager.NetworkConfig.TickRate}) | Tick Wait ({count}) | TargetFrameRate ({Application.targetFrameRate}) | Target Frames ({framesPerTick * count})\n");
|
||||
yield return WaitForTickAndFrames(networkManager, count, totalFrameCount);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -182,11 +182,8 @@ namespace Unity.Netcode.TestHelpers.Runtime
|
||||
unityTransport.ConnectTimeoutMS = 500;
|
||||
|
||||
// Set the NetworkConfig
|
||||
networkManager.NetworkConfig = new NetworkConfig()
|
||||
{
|
||||
// Set transport
|
||||
NetworkTransport = unityTransport
|
||||
};
|
||||
networkManager.NetworkConfig ??= new NetworkConfig();
|
||||
networkManager.NetworkConfig.NetworkTransport = unityTransport;
|
||||
}
|
||||
|
||||
public static NetworkManager CreateServer()
|
||||
@@ -486,6 +483,34 @@ namespace Unity.Netcode.TestHelpers.Runtime
|
||||
}
|
||||
}
|
||||
|
||||
public static GameObject CreateNetworkObjectPrefab(string baseName, NetworkManager server, params NetworkManager[] clients)
|
||||
{
|
||||
void AddNetworkPrefab(NetworkConfig config, NetworkPrefab prefab)
|
||||
{
|
||||
config.Prefabs.Add(prefab);
|
||||
}
|
||||
|
||||
var prefabCreateAssertError = $"You can only invoke this method before starting the network manager(s)!";
|
||||
Assert.IsNotNull(server, prefabCreateAssertError);
|
||||
Assert.IsFalse(server.IsListening, prefabCreateAssertError);
|
||||
|
||||
var gameObject = new GameObject();
|
||||
gameObject.name = baseName;
|
||||
var networkObject = gameObject.AddComponent<NetworkObject>();
|
||||
networkObject.NetworkManagerOwner = server;
|
||||
MakeNetworkObjectTestPrefab(networkObject);
|
||||
var networkPrefab = new NetworkPrefab() { Prefab = gameObject };
|
||||
|
||||
// We could refactor this test framework to share a NetworkPrefabList instance, but at this point it's
|
||||
// probably more trouble than it's worth to verify these lists stay in sync across all tests...
|
||||
AddNetworkPrefab(server.NetworkConfig, networkPrefab);
|
||||
foreach (var clientNetworkManager in clients)
|
||||
{
|
||||
AddNetworkPrefab(clientNetworkManager.NetworkConfig, networkPrefab);
|
||||
}
|
||||
return gameObject;
|
||||
}
|
||||
|
||||
// We use GameObject instead of SceneObject to be able to keep hierarchy
|
||||
public static void MarkAsSceneObjectRoot(GameObject networkObjectRoot, NetworkManager server, NetworkManager[] clients)
|
||||
{
|
||||
@@ -512,15 +537,6 @@ namespace Unity.Netcode.TestHelpers.Runtime
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Waits (yields) until specified amount of network ticks has been passed.
|
||||
/// </summary>
|
||||
public static IEnumerator WaitForTicks(NetworkManager networkManager, int count)
|
||||
{
|
||||
var targetTick = networkManager.NetworkTickSystem.LocalTime.Tick + count;
|
||||
yield return new WaitUntil(() => networkManager.NetworkTickSystem.LocalTime.Tick >= targetTick);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Waits on the client side to be connected.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user