mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 02:50:32 +00:00
NetworkServer.DestroyObject(GameObject) helper function to reuse in UnSpawn and Destroy
This commit is contained in:
parent
820070cf60
commit
e80ec86577
@ -1271,12 +1271,7 @@ static void DestroyObject(NetworkIdentity identity, bool destroyServerObject)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
static void DestroyObject(GameObject obj, bool destroyServerObject)
|
||||||
/// Destroys this object and corresponding objects on all clients.
|
|
||||||
/// <para>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().</para>
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="obj">Game object to destroy.</param>
|
|
||||||
public static void Destroy(GameObject obj)
|
|
||||||
{
|
{
|
||||||
if (obj == null)
|
if (obj == null)
|
||||||
{
|
{
|
||||||
@ -1286,29 +1281,24 @@ public static void Destroy(GameObject obj)
|
|||||||
|
|
||||||
if (GetNetworkIdentity(obj, out NetworkIdentity identity))
|
if (GetNetworkIdentity(obj, out NetworkIdentity identity))
|
||||||
{
|
{
|
||||||
DestroyObject(identity, true);
|
DestroyObject(identity, destroyServerObject);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Destroys this object and corresponding objects on all clients.
|
||||||
|
/// <para>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().</para>
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="obj">Game object to destroy.</param>
|
||||||
|
public static void Destroy(GameObject obj) => DestroyObject(obj, true);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This takes an object that has been spawned and un-spawns it.
|
/// This takes an object that has been spawned and un-spawns it.
|
||||||
/// <para>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.</para>
|
/// <para>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.</para>
|
||||||
/// <para>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.</para>
|
/// <para>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.</para>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="obj">The spawned object to be unspawned.</param>
|
/// <param name="obj">The spawned object to be unspawned.</param>
|
||||||
public static void UnSpawn(GameObject obj)
|
public static void UnSpawn(GameObject obj) => DestroyObject(obj, false);
|
||||||
{
|
|
||||||
if (obj == null)
|
|
||||||
{
|
|
||||||
Debug.Log("NetworkServer UnspawnObject is null");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GetNetworkIdentity(obj, out NetworkIdentity identity))
|
|
||||||
{
|
|
||||||
DestroyObject(identity, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
internal static bool ValidateSceneObject(NetworkIdentity identity)
|
internal static bool ValidateSceneObject(NetworkIdentity identity)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user