Open Marc477 opened 1 year ago
I think i found the issue:
Please change line 70 in WebSocketClientFactory.cs
so that that it checks if its using the Unity Editor
public static IWebSocketClient Create(string url)
{
#if UNITY_WEBGL && !UNITY_EDITOR // <---------------- Fix this line by adding && !UNITY_EDITOR
_SetUrl(url);
_SetOnOpen(OnOpenEvent);
_SetOnMessage(OnMessageEvent);
_SetOnError(OnErrorEvent);
_SetOnClose(OnCloseEvent);
return Client;
#else
return new NativeWebSocketClient(url);
#endif
}
Because when in the Unity editor, the webgl external functions won't work. So it needs to call the NativeWebSocket instead from the editor.
This happens when trying to call StartClient() the port is set to 7700 and the url to 127.0.0.1. My code has been tested with Unity Transport and it works well. This is when i change to WebSocketTransport. In my build settings the platform is set to WebGL. Netcode 1.0.2. Unity 2020.3.37
EntryPointNotFoundException: _SetUrl Netcode.Transports.WebSocket.WebSocketClientFactory.Create (System.String url) (at Library/PackageCache/com.community.netcode.transport.websocket@e9f53f86a0/Runtime/WebSocketClientFactory.cs:71) Netcode.Transports.WebSocket.WebSocketTransport.StartClient () (at Library/PackageCache/com.community.netcode.transport.websocket@e9f53f86a0/Runtime/WebSocketTransport.cs:114) Unity.Netcode.NetworkManager.StartClient () (at Library/PackageCache/com.unity.netcode.gameobjects@1.0.2/Runtime/Core/NetworkManager.cs:1068)
The resulting URL inside the Create function of WebSocketClientFactory is : "ws://127.0.0.1:7700/netcode"