CreateNetworkedAndSpawn without component helper function

This commit is contained in:
vis2k 2021-08-07 19:15:01 +08:00
parent aff28a0c07
commit 0fdb39fa1c

View File

@ -138,6 +138,21 @@ protected void CreateNetworked<T, U, V>(out GameObject go, out NetworkIdentity i
instantiated.Add(go);
}
// create GameObject + NetworkIdentity + NetworkBehaviour & SPAWN
// => ownerConnection can be NetworkServer.localConnection if needed.
protected void CreateNetworkedAndSpawn(out GameObject go, out NetworkIdentity identity, NetworkConnection ownerConnection = null)
{
// 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.");
CreateNetworked(out go, out identity);
// spawn
NetworkServer.Spawn(go, ownerConnection);
ProcessMessages();
}
// create GameObject + NetworkIdentity + NetworkBehaviour & SPAWN
// => ownerConnection can be NetworkServer.localConnection if needed.
protected void CreateNetworkedAndSpawn<T>(out GameObject go, out NetworkIdentity identity, out T component, NetworkConnection ownerConnection = null)