[Command] tests: set up NetworkIdentity connectionToServer everywhere too, not just to client. prepares for making SendCommandInternal use connectionToServer instead of NetworkClient.readyConnection.

This commit is contained in:
vis2k 2021-03-10 19:04:08 +08:00
parent b3c25d1094
commit a58cd37a36
2 changed files with 7 additions and 1 deletions

View File

@ -316,7 +316,10 @@ public void SendCommandInternal()
isAuthenticated = true
};
connection.connectionToServer.connectionToClient = connection;
// host needs connection to both directions
identity.connectionToClient = connection;
identity.connectionToServer = connection.connectionToServer;
// calling command before client is connected shouldn't work
// error log is expected

View File

@ -58,7 +58,10 @@ protected T CreateHostObject<T>(bool spawnWithAuthority) where T : NetworkBehavi
GameObject gameObject = new GameObject();
spawned.Add(gameObject);
gameObject.AddComponent<NetworkIdentity>();
NetworkIdentity netIdentity = gameObject.AddComponent<NetworkIdentity>();
// host mode object needs a connection to server for commands to work
netIdentity.connectionToServer = NetworkClient.readyConnection;
T behaviour = gameObject.AddComponent<T>();