Naturally when I call StartHost twice on the same pc I get an error that port is already in use.
I'd like to know if there is a way to silence this error. Currently I've created simple script which i've added to my scene to speed up testing (so I can launch game and skip the entry menu). But when I hit play in unity editor it stops on the start host error. Then i can unpause game and it continues normally. It's kind of annoying I'm getting the error and I have to hit "unpause" every time. Is there any way to catch new networking errors? Because try/catch does not seem to work.
public class TestGameStarter : MonoBehaviour {
private NetworkManager networkManager;
void Start () {
networkManager = GameObject.FindWithTag(Tags.NETWORK_MANAGER).GetComponent();
if(networkManager.client == null)
{
networkManager.StartupHost();
if(networkManager.client) {
NetworkManager.singleton.networkAddress = "";
networkManager.JoinGame();
}
}
}
}
↧