mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 19:10:32 +00:00
fix: NetworkServer.Destroy now warns instead of throwing for null objects again
This commit is contained in:
parent
c15d465874
commit
b90f6f30ab
@ -1559,7 +1559,7 @@ public static void UnSpawn(GameObject obj)
|
|||||||
{
|
{
|
||||||
// Debug.Log($"DestroyObject instance:{identity.netId}");
|
// Debug.Log($"DestroyObject instance:{identity.netId}");
|
||||||
|
|
||||||
// NetworkServer.Destroy should only be called on server or host.
|
// NetworkServer.Unspawn should only be called on server or host.
|
||||||
// on client, show a warning to explain what it does.
|
// on client, show a warning to explain what it does.
|
||||||
if (!active)
|
if (!active)
|
||||||
{
|
{
|
||||||
@ -1640,6 +1640,20 @@ public static void UnSpawn(GameObject obj)
|
|||||||
// NetworkServer.Destroy().
|
// NetworkServer.Destroy().
|
||||||
public static void Destroy(GameObject obj)
|
public static void Destroy(GameObject obj)
|
||||||
{
|
{
|
||||||
|
// NetworkServer.Destroy should only be called on server or host.
|
||||||
|
// on client, show a warning to explain what it does.
|
||||||
|
if (!active)
|
||||||
|
{
|
||||||
|
Debug.LogWarning("NetworkServer.Destroy() called without an active server. Servers can only destroy while active, clients can only ask the server to destroy (for example, with a [Command]), after which the server may decide to destroy the object and broadcast the change to all clients.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (obj == null)
|
||||||
|
{
|
||||||
|
Debug.Log("NetworkServer.Destroy(): object is null");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// first, we unspawn it on clients and server
|
// first, we unspawn it on clients and server
|
||||||
UnSpawn(obj);
|
UnSpawn(obj);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user