Catch/ignore NetworkManager.StartHost error
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<NetworkManager>();
if(networkManager.client == null)
{
networkManager.StartupHost();
if(networkManager.client) {
NetworkManager.singleton.networkAddress = "<removed>";
networkManager.JoinGame();
}
}
}
}
Your answer
Follow this Question
Related Questions
Problem connection server unet 0 Answers
Unity VR WebSocket Connection to ThingsBoard Error 'Failed to parse websocket command!' 1 Answer
Network Transform synchronizes only rotation but not movement 1 Answer
Mirror network error : There is already a player for this connection. 1 Answer
Need some help with networking, Object reference not set to an instance of an object. 0 Answers