NetworkManager - How to set path of UnityTransport Websocket (TCP)?

Hi, I have a webgl project with a NetworkManager.

After setting the UnityTransport, in my startup script I can set the server address and port like this:

NetworkManager.Singleton.GetComponent<UnityTransport>().ConnectionData.Address = _netcodeUrl;
NetworkManager.Singleton.GetComponent<UnityTransport>().ConnectionData.Port = _netcodePort;

And flag “Use WebSocket” in the inspector.

Now I need to specify a path too, but i cannot understand HOW to set it. I expected something like:

NetworkManager.Singleton.GetComponent<UnityTransport>().ConnectionData.Path = _myPath;

but apparently there is no option like this.

In the UnityTransort manual I find this code:

var settings = new NetworkSettings();
settings.WithWebSocketParameters(path: "/some/path");
var driver = NetworkDriver.Create(new WebSocketNetworkInterface(), settings);

How can i set this driver in the UnityTransport used by NetworkManager?

I find this method:

NetworkManager.Singleton.GetComponent<UnityTransport>().CreateDriver();

where one of the parameters is a Network driver, but I’m not sure if it’s the correct waty to set it, and anyway I cannot understand how to the set the other parameters.

Thanks

1 Like