diff --git a/Assets/Mirror/Runtime/NetworkServer.cs b/Assets/Mirror/Runtime/NetworkServer.cs index 4b2a77352..c399d155b 100644 --- a/Assets/Mirror/Runtime/NetworkServer.cs +++ b/Assets/Mirror/Runtime/NetworkServer.cs @@ -1271,12 +1271,7 @@ static void DestroyObject(NetworkIdentity identity, bool destroyServerObject) } } - /// - /// Destroys this object and corresponding objects on all clients. - /// In some cases it is useful to remove an object but not delete it on the server. For that, use NetworkServer.UnSpawn() instead of NetworkServer.Destroy(). - /// - /// Game object to destroy. - public static void Destroy(GameObject obj) + static void DestroyObject(GameObject obj, bool destroyServerObject) { if (obj == null) { @@ -1286,29 +1281,24 @@ public static void Destroy(GameObject obj) if (GetNetworkIdentity(obj, out NetworkIdentity identity)) { - DestroyObject(identity, true); + DestroyObject(identity, destroyServerObject); } } + /// + /// Destroys this object and corresponding objects on all clients. + /// In some cases it is useful to remove an object but not delete it on the server. For that, use NetworkServer.UnSpawn() instead of NetworkServer.Destroy(). + /// + /// Game object to destroy. + public static void Destroy(GameObject obj) => DestroyObject(obj, true); + /// /// This takes an object that has been spawned and un-spawns it. /// The object will be removed from clients that it was spawned on, or the custom spawn handler function on the client will be called for the object. /// Unlike when calling NetworkServer.Destroy(), on the server the object will NOT be destroyed. This allows the server to re-use the object, even spawn it again later. /// /// The spawned object to be unspawned. - public static void UnSpawn(GameObject obj) - { - if (obj == null) - { - Debug.Log("NetworkServer UnspawnObject is null"); - return; - } - - if (GetNetworkIdentity(obj, out NetworkIdentity identity)) - { - DestroyObject(identity, false); - } - } + public static void UnSpawn(GameObject obj) => DestroyObject(obj, false); internal static bool ValidateSceneObject(NetworkIdentity identity) {