com.unity.netcode.gameobjects@2.0.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). ## [2.0.0] - 2024-09-12 ### Added - Added tooltips for all of the `NetworkObject` component's properties. (#3052) - Added message size validation to named and unnamed message sending functions for better error messages. (#3049) - Added "Check for NetworkObject Component" property to the Multiplayer->Netcode for GameObjects project settings. When disabled, this will bypass the in-editor `NetworkObject` check on `NetworkBehaviour` components. (#3031) - Added `NetworkTransform.SwitchTransformSpaceWhenParented` property that, when enabled, will handle the world to local, local to world, and local to local transform space transitions when interpolation is enabled. (#3013) - Added `NetworkTransform.TickSyncChildren` that, when enabled, will tick synchronize nested and/or child `NetworkTransform` components to eliminate any potential visual jittering that could occur if the `NetworkTransform` instances get into a state where their state updates are landing on different network ticks. (#3013) - Added `NetworkObject.AllowOwnerToParent` property to provide the ability to allow clients to parent owned objects when running in a client-server network topology. (#3013) - Added `NetworkObject.SyncOwnerTransformWhenParented` property to provide a way to disable applying the server's transform information in the parenting message on the client owner instance which can be useful for owner authoritative motion models. (#3013) - Added `NetcodeEditorBase` editor helper class to provide easier modification and extension of the SDK's components. (#3013) ### Fixed - Fixed issue where `NetworkAnimator` would send updates to non-observer clients. (#3057) - Fixed issue where an exception could occur when receiving a universal RPC for a `NetworkObject` that has been despawned. (#3052) - Fixed issue where a NetworkObject hidden from a client that is then promoted to be session owner was not being synchronized with newly joining clients.(#3051) - Fixed issue where clients could have a wrong time delta on `NetworkVariableBase` which could prevent from sending delta state updates. (#3045) - Fixed issue where setting a prefab hash value during connection approval but not having a player prefab assigned could cause an exception when spawning a player. (#3042) - Fixed issue where the `NetworkSpawnManager.HandleNetworkObjectShow` could throw an exception if one of the `NetworkObject` components to show was destroyed during the same frame. (#3030) - Fixed issue where the `NetworkManagerHelper` was continuing to check for hierarchy changes when in play mode. (#3026) - Fixed issue with newly/late joined clients and `NetworkTransform` synchronization of parented `NetworkObject` instances. (#3013) - Fixed issue with smooth transitions between transform spaces when interpolation is enabled (requires `NetworkTransform.SwitchTransformSpaceWhenParented` to be enabled). (#3013) ### Changed - Changed `NetworkTransformEditor` now uses `NetworkTransform` as the base type class to assure it doesn't display a foldout group when using the base `NetworkTransform` component class. (#3052) - Changed `NetworkAnimator.Awake` is now a protected virtual method. (#3052) - Changed when invoking `NetworkManager.ConnectionManager.DisconnectClient` during a distributed authority session a more appropriate message is logged. (#3052) - Changed `NetworkTransformEditor` so it now derives from `NetcodeEditorBase`. (#3013) - Changed `NetworkRigidbodyBaseEditor` so it now derives from `NetcodeEditorBase`. (#3013) - Changed `NetworkManagerEditor` so it now derives from `NetcodeEditorBase`. (#3013)
This commit is contained in:
@@ -14,9 +14,11 @@ namespace Unity.Netcode.RuntimeTests
|
||||
internal class NetworkVisibilityTests : NetcodeIntegrationTest
|
||||
{
|
||||
|
||||
protected override int NumberOfClients => 1;
|
||||
protected override int NumberOfClients => 2;
|
||||
private GameObject m_TestNetworkPrefab;
|
||||
private bool m_SceneManagementEnabled;
|
||||
private GameObject m_SpawnedObject;
|
||||
private NetworkManager m_SessionOwner;
|
||||
|
||||
public NetworkVisibilityTests(SceneManagementState sceneManagementState, NetworkTopologyTypes networkTopologyType) : base(networkTopologyType)
|
||||
{
|
||||
@@ -27,7 +29,11 @@ namespace Unity.Netcode.RuntimeTests
|
||||
{
|
||||
m_TestNetworkPrefab = CreateNetworkObjectPrefab("Object");
|
||||
m_TestNetworkPrefab.AddComponent<NetworkVisibilityComponent>();
|
||||
m_ServerNetworkManager.NetworkConfig.EnableSceneManagement = m_SceneManagementEnabled;
|
||||
if (!UseCMBService())
|
||||
{
|
||||
m_ServerNetworkManager.NetworkConfig.EnableSceneManagement = m_SceneManagementEnabled;
|
||||
}
|
||||
|
||||
foreach (var clientNetworkManager in m_ClientNetworkManagers)
|
||||
{
|
||||
clientNetworkManager.NetworkConfig.EnableSceneManagement = m_SceneManagementEnabled;
|
||||
@@ -38,7 +44,8 @@ namespace Unity.Netcode.RuntimeTests
|
||||
|
||||
protected override IEnumerator OnServerAndClientsConnected()
|
||||
{
|
||||
SpawnObject(m_TestNetworkPrefab, m_ServerNetworkManager);
|
||||
m_SessionOwner = UseCMBService() ? m_ClientNetworkManagers[0] : m_ServerNetworkManager;
|
||||
m_SpawnedObject = SpawnObject(m_TestNetworkPrefab, m_SessionOwner);
|
||||
|
||||
yield return base.OnServerAndClientsConnected();
|
||||
}
|
||||
@@ -46,13 +53,49 @@ namespace Unity.Netcode.RuntimeTests
|
||||
[UnityTest]
|
||||
public IEnumerator HiddenObjectsTest()
|
||||
{
|
||||
var expectedCount = UseCMBService() ? 2 : 3;
|
||||
#if UNITY_2023_1_OR_NEWER
|
||||
yield return WaitForConditionOrTimeOut(() => Object.FindObjectsByType<NetworkVisibilityComponent>(FindObjectsSortMode.None).Where((c) => c.IsSpawned).Count() == 2);
|
||||
yield return WaitForConditionOrTimeOut(() => Object.FindObjectsByType<NetworkVisibilityComponent>(FindObjectsSortMode.None).Where((c) => c.IsSpawned).Count() == expectedCount);
|
||||
#else
|
||||
yield return WaitForConditionOrTimeOut(() => Object.FindObjectsOfType<NetworkVisibilityComponent>().Where((c) => c.IsSpawned).Count() == 2);
|
||||
yield return WaitForConditionOrTimeOut(() => Object.FindObjectsOfType<NetworkVisibilityComponent>().Where((c) => c.IsSpawned).Count() == expectedCount);
|
||||
#endif
|
||||
|
||||
Assert.IsFalse(s_GlobalTimeoutHelper.TimedOut, "Timed out waiting for the visible object count to equal 2!");
|
||||
}
|
||||
|
||||
[UnityTest]
|
||||
public IEnumerator HideShowAndDeleteTest()
|
||||
{
|
||||
var expectedCount = UseCMBService() ? 2 : 3;
|
||||
#if UNITY_2023_1_OR_NEWER
|
||||
yield return WaitForConditionOrTimeOut(() => Object.FindObjectsByType<NetworkVisibilityComponent>(FindObjectsSortMode.None).Where((c) => c.IsSpawned).Count() == expectedCount);
|
||||
#else
|
||||
yield return WaitForConditionOrTimeOut(() => Object.FindObjectsOfType<NetworkVisibilityComponent>().Where((c) => c.IsSpawned).Count() == expectedCount);
|
||||
#endif
|
||||
AssertOnTimeout("Timed out waiting for the visible object count to equal 2!");
|
||||
|
||||
var sessionOwnerNetworkObject = m_SpawnedObject.GetComponent<NetworkObject>();
|
||||
var clientIndex = UseCMBService() ? 1 : 0;
|
||||
sessionOwnerNetworkObject.NetworkHide(m_ClientNetworkManagers[clientIndex].LocalClientId);
|
||||
#if UNITY_2023_1_OR_NEWER
|
||||
yield return WaitForConditionOrTimeOut(() => Object.FindObjectsByType<NetworkVisibilityComponent>(FindObjectsSortMode.None).Where((c) => c.IsSpawned).Count() == expectedCount - 1);
|
||||
#else
|
||||
yield return WaitForConditionOrTimeOut(() => Object.FindObjectsOfType<NetworkVisibilityComponent>().Where((c) => c.IsSpawned).Count() == expectedCount - 1);
|
||||
#endif
|
||||
AssertOnTimeout($"Timed out waiting for {m_SpawnedObject.name} to be hidden from client!");
|
||||
var networkObjectId = sessionOwnerNetworkObject.NetworkObjectId;
|
||||
sessionOwnerNetworkObject.NetworkShow(m_ClientNetworkManagers[clientIndex].LocalClientId);
|
||||
sessionOwnerNetworkObject.Despawn(true);
|
||||
|
||||
// Expect no exceptions
|
||||
yield return s_DefaultWaitForTick;
|
||||
|
||||
// Now force a scenario where it normally would have caused an exception
|
||||
m_SessionOwner.SpawnManager.ObjectsToShowToClient.Add(m_ClientNetworkManagers[clientIndex].LocalClientId, new System.Collections.Generic.List<NetworkObject>());
|
||||
m_SessionOwner.SpawnManager.ObjectsToShowToClient[m_ClientNetworkManagers[clientIndex].LocalClientId].Add(null);
|
||||
|
||||
// Expect no exceptions
|
||||
yield return s_DefaultWaitForTick;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user