mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 02:50:32 +00:00
NetworkServer.Destroy: add warning if called on client without server/host to make this more obvious, instead of destroying something locally that doesn't persist on the server (#3604)
This commit is contained in:
parent
c49d188e8b
commit
c903298513
@ -1492,6 +1492,14 @@ static void DestroyObject(NetworkIdentity identity, DestroyMode mode)
|
|||||||
{
|
{
|
||||||
// Debug.Log($"DestroyObject instance:{identity.netId}");
|
// Debug.Log($"DestroyObject instance:{identity.netId}");
|
||||||
|
|
||||||
|
// 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;
|
||||||
|
}
|
||||||
|
|
||||||
// only call OnRebuildObservers while active,
|
// only call OnRebuildObservers while active,
|
||||||
// not while shutting down
|
// not while shutting down
|
||||||
// (https://github.com/vis2k/Mirror/issues/2977)
|
// (https://github.com/vis2k/Mirror/issues/2977)
|
||||||
|
Loading…
Reference in New Issue
Block a user