I’m working with Netcode for Game Objects in Unity 6.0 using UnityTransport and FacepunchTransport (separately) How can I do something like that?
try
{
NetworkManager.Singleton.StartHost(); // Port already binded error
// NetworkManager.Singleton.StartClient(); // Connection Timeout
}
catch (System.Exception e)
{
OutputScreen.Instance.ShowScreen(e.Message, "Return", null);
}
If something goes wrong, i have no way to tell the user what happened, just a generic error message. I want to be more in control about errors and stuff like that. Do I need to acess a event on the tranposer itself to get errors like these?
I don’t think there are any exceptions thrown upon start, but you can check if it failed:
if (NetworkManager.Singleton.StartHost() == false)
Debug.LogError("..");
Normall you don’t need a detailed failure message. Check if something like “port already bound” gets logged to player.log. If so, users will figure that out. On the UI side it would suffice to tell “StartHost failed, check player.log”.
You should implement OnTransportFailure because these can occur at any time, ie LAN cable unplugged. But again nothing specific in there.
1 Like
Oh, i see! I checked everywhere for a callback onError, but forgot to just check the result of it. Thanks for the quick reply!