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:
@@ -0,0 +1,154 @@
|
||||
using System.Collections;
|
||||
using NUnit.Framework;
|
||||
using Unity.Netcode.TestHelpers.Runtime;
|
||||
using UnityEngine;
|
||||
using UnityEngine.TestTools;
|
||||
|
||||
namespace Unity.Netcode.RuntimeTests
|
||||
{
|
||||
[TestFixture(HostOrServer.DAHost, true)]
|
||||
[TestFixture(HostOrServer.DAHost, false)]
|
||||
public class ExtendedNetworkShowAndHideTests : NetcodeIntegrationTest
|
||||
{
|
||||
protected override int NumberOfClients => 3;
|
||||
private bool m_EnableSceneManagement;
|
||||
private GameObject m_ObjectToSpawn;
|
||||
private NetworkObject m_SpawnedObject;
|
||||
private NetworkManager m_ClientToHideFrom;
|
||||
private NetworkManager m_LateJoinClient;
|
||||
private NetworkManager m_SpawnOwner;
|
||||
|
||||
public ExtendedNetworkShowAndHideTests(HostOrServer hostOrServer, bool enableSceneManagement) : base(hostOrServer)
|
||||
{
|
||||
m_EnableSceneManagement = enableSceneManagement;
|
||||
}
|
||||
|
||||
protected override void OnServerAndClientsCreated()
|
||||
{
|
||||
if (!UseCMBService())
|
||||
{
|
||||
m_ServerNetworkManager.NetworkConfig.EnableSceneManagement = m_EnableSceneManagement;
|
||||
}
|
||||
|
||||
foreach (var client in m_ClientNetworkManagers)
|
||||
{
|
||||
client.NetworkConfig.EnableSceneManagement = m_EnableSceneManagement;
|
||||
}
|
||||
|
||||
m_ObjectToSpawn = CreateNetworkObjectPrefab("TestObject");
|
||||
m_ObjectToSpawn.SetActive(false);
|
||||
|
||||
base.OnServerAndClientsCreated();
|
||||
}
|
||||
|
||||
private bool AllClientsSpawnedObject()
|
||||
{
|
||||
if (!UseCMBService())
|
||||
{
|
||||
if (!s_GlobalNetworkObjects.ContainsKey(m_ServerNetworkManager.LocalClientId))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (!s_GlobalNetworkObjects[m_ServerNetworkManager.LocalClientId].ContainsKey(m_SpawnedObject.NetworkObjectId))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var client in m_ClientNetworkManagers)
|
||||
{
|
||||
if (!s_GlobalNetworkObjects.ContainsKey(client.LocalClientId))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (!s_GlobalNetworkObjects[client.LocalClientId].ContainsKey(m_SpawnedObject.NetworkObjectId))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool IsClientPromotedToSessionOwner()
|
||||
{
|
||||
if (!UseCMBService())
|
||||
{
|
||||
if (m_ServerNetworkManager.CurrentSessionOwner != m_ClientToHideFrom.LocalClientId)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var client in m_ClientNetworkManagers)
|
||||
{
|
||||
if (!client.IsConnectedClient)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (client.CurrentSessionOwner != m_ClientToHideFrom.LocalClientId)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override void OnNewClientCreated(NetworkManager networkManager)
|
||||
{
|
||||
m_LateJoinClient = networkManager;
|
||||
networkManager.NetworkConfig.EnableSceneManagement = m_EnableSceneManagement;
|
||||
networkManager.NetworkConfig.Prefabs = m_SpawnOwner.NetworkConfig.Prefabs;
|
||||
base.OnNewClientCreated(networkManager);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This test validates the following NetworkShow - NetworkHide issue:
|
||||
/// - During a session, a spawned object is hidden from a client.
|
||||
/// - The current session owner disconnects and the client the object is hidden from is prommoted to the session owner.
|
||||
/// - A new client joins and the newly promoted session owner synchronizes the newly joined client with only objects visible to it.
|
||||
/// - Any already connected non-session owner client should "NetworkShow" the object to the newly connected client
|
||||
/// (but only if the hidden object has SpawnWithObservers enabled)
|
||||
/// </summary>
|
||||
[UnityTest]
|
||||
public IEnumerator HiddenObjectPromotedSessionOwnerNewClientSynchronizes()
|
||||
{
|
||||
// Get the test relative session owner
|
||||
var sessionOwner = UseCMBService() ? m_ClientNetworkManagers[0] : m_ServerNetworkManager;
|
||||
m_SpawnOwner = UseCMBService() ? m_ClientNetworkManagers[1] : m_ClientNetworkManagers[0];
|
||||
m_ClientToHideFrom = UseCMBService() ? m_ClientNetworkManagers[NumberOfClients - 1] : m_ClientNetworkManagers[1];
|
||||
m_ObjectToSpawn.SetActive(true);
|
||||
|
||||
// Spawn the object with a non-session owner client
|
||||
m_SpawnedObject = SpawnObject(m_ObjectToSpawn, m_SpawnOwner).GetComponent<NetworkObject>();
|
||||
yield return WaitForConditionOrTimeOut(AllClientsSpawnedObject);
|
||||
AssertOnTimeout($"Not all clients spawned and instance of {m_SpawnedObject.name}");
|
||||
|
||||
// Hide the spawned object from the to be promoted session owner
|
||||
m_SpawnedObject.NetworkHide(m_ClientToHideFrom.LocalClientId);
|
||||
|
||||
yield return WaitForConditionOrTimeOut(() => !m_ClientToHideFrom.SpawnManager.SpawnedObjects.ContainsKey(m_SpawnedObject.NetworkObjectId));
|
||||
AssertOnTimeout($"{m_SpawnedObject.name} was not hidden from Client-{m_ClientToHideFrom.LocalClientId}!");
|
||||
|
||||
// Promoted a new session owner (DAHost promotes while CMB Session we disconnect the current session owner)
|
||||
if (!UseCMBService())
|
||||
{
|
||||
m_ServerNetworkManager.PromoteSessionOwner(m_ClientToHideFrom.LocalClientId);
|
||||
}
|
||||
else
|
||||
{
|
||||
sessionOwner.Shutdown();
|
||||
}
|
||||
|
||||
// Wait for the new session owner to be promoted and for all clients to acknowledge the promotion
|
||||
yield return WaitForConditionOrTimeOut(IsClientPromotedToSessionOwner);
|
||||
AssertOnTimeout($"Client-{m_ClientToHideFrom.LocalClientId} was not promoted as session owner on all client instances!");
|
||||
|
||||
// Connect a new client instance
|
||||
yield return CreateAndStartNewClient();
|
||||
|
||||
// Assure the newly connected client is synchronized with the NetworkObject hidden from the newly promoted session owner
|
||||
yield return WaitForConditionOrTimeOut(() => m_LateJoinClient.SpawnManager.SpawnedObjects.ContainsKey(m_SpawnedObject.NetworkObjectId));
|
||||
AssertOnTimeout($"Client-{m_LateJoinClient.LocalClientId} never spawned {nameof(NetworkObject)} {m_SpawnedObject.name}!");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a6389d04d9080b24b99de7e6900a064c
|
||||
Reference in New Issue
Block a user