NetworkServer.SpawnObject shows a warning when called with a server-only NetworkIdentity

This commit is contained in:
vis2k 2020-08-27 14:27:49 +02:00
parent f6dbf8c19e
commit ede2c6c2c2

View File

@ -1060,6 +1060,14 @@ internal static void SpawnObject(GameObject obj, NetworkConnection ownerConnecti
return; return;
} }
// spawning a server-only NetworkIdentity won't do anything, but
// might confuse someone. let's show a warning.
if (identity.serverOnly)
{
logger.LogWarning("SpawnObject for " + obj + " is server-only. Calling NetworkServer.Spawn wouldn't do anything.");
return;
}
if (identity.SpawnedFromInstantiate) if (identity.SpawnedFromInstantiate)
{ {
// Using Instantiate on SceneObject is not allowed, so stop spawning here // Using Instantiate on SceneObject is not allowed, so stop spawning here