Class NetworkObjectDestroyTests
Tests calling destroy on spawned / unspawned NetworkObjects. Expected behavior:
- Server or client destroy on unspawned => Object gets destroyed, no exceptions
- Server destroy spawned => Object gets destroyed and despawned/destroyed on all clients. Server does not run NetworkPrefaInstanceHandler.HandleNetworkPrefabDestroy. Client runs it.
- Client destroy spawned => throw exception.
Inherited Members
Namespace: Unity.Netcode.RuntimeTests
Assembly: Unity.Netcode.RuntimeTests.dll
Syntax
public class NetworkObjectDestroyTests : NetcodeIntegrationTest
Properties
NumberOfClients
Gets the number of clients to be created for the integration test.
Declaration
protected override int NumberOfClients { get; }
Property Value
| Type | Description |
|---|---|
| int |
Overrides
Methods
OnTearDown()
Note: For PerTest mode this is called before ShutdownAndCleanUp.
Declaration
protected override IEnumerator OnTearDown()
Returns
| Type | Description |
|---|---|
| IEnumerator | An IEnumerator for use with Unity's coroutine system. |
Overrides
TestNetworkObjectClientDestroy(ClientDestroyObject)
Validates the expected behavior when the client-side destroys a NetworkObject
Declaration
[UnityTest]
public IEnumerator TestNetworkObjectClientDestroy(NetworkObjectDestroyTests.ClientDestroyObject clientDestroyObject)
Parameters
| Type | Name | Description |
|---|---|---|
| NetworkObjectDestroyTests.ClientDestroyObject | clientDestroyObject |
Returns
| Type | Description |
|---|---|
| IEnumerator |
TestNetworkObjectServerDestroy()
Tests that a server can destroy a NetworkObject and that it gets despawned correctly.
Declaration
[UnityTest]
public IEnumerator TestNetworkObjectServerDestroy()
Returns
| Type | Description |
|---|---|
| IEnumerator | An IEnumerator for the UnityTest coroutine that validates object destruction and cleanup. |