MirrorTests: CreateNetworkedAndSpawnPlayer without <T> helper function

This commit is contained in:
vis2k 2021-08-10 19:11:05 +08:00
parent 881d90f539
commit 87478178e9

View File

@ -223,6 +223,23 @@ protected void CreateNetworkedAndSpawn<T, U, V>(out GameObject go, out NetworkId
}
}
// create GameObject + NetworkIdentity + NetworkBehaviour & SPAWN PLAYER.
// often times, we really need a player object for the client to receive
// certain messages.
protected void CreateNetworkedAndSpawnPlayer(out GameObject go, out NetworkIdentity identity, NetworkConnection ownerConnection)
{
// server & client need to be active before spawning
Debug.Assert(NetworkClient.active, "NetworkClient needs to be active before spawning.");
Debug.Assert(NetworkServer.active, "NetworkServer needs to be active before spawning.");
// create a networked object
CreateNetworked(out go, out identity);
// add as player & process spawn message on client.
NetworkServer.AddPlayerForConnection(ownerConnection, go);
ProcessMessages();
}
// create GameObject + NetworkIdentity + NetworkBehaviour & SPAWN PLAYER.
// often times, we really need a player object for the client to receive
// certain messages.