Closed kentakang closed 2 years ago
Tested, This works!! Thanks
cc @endel
Hey, thanks for the PR. Is this backward-compatible with previous versions of Unity as well?
On which unity version does it work?
I have 2021.2.7f1 and I am getting the following error:
Invoking error handler due to
ReferenceError: Runtime is not defined
at WebSocket.instance.ws.onopen (http://localhost:54696/Build/nativewebsocket.framework.js:2536:30)
It seams that in unity 2021.2 variable Runtime doesn't exist and can be replaced with Module['dynCall_*'].
In webSocket.jslib change all Runtime.dynCall('1', 2, [3, 4]) for Module['dynCall_1'](2, 3, 4)
Example instance.ws.onopen function in WebSocket.jslib:
change Runtime.dynCall('vi', webSocketState.onOpen, [ instanceId ]);
for
Module['dynCall_vi'](webSocketState.onOpen, instanceId);
I've tested this using Unity 2021.2.6 and 2021.2.7, works like a charm.
It also works on Unity 2020.3.20
It seams that in unity 2021.2 variable Runtime doesn't exist and can be replaced with Module['dynCall_*'].
In webSocket.jslib change all Runtime.dynCall('1', 2, [3, 4]) for Module['dynCall_1'](2, 3, 4)
Example instance.ws.onopen function in WebSocket.jslib:
change Runtime.dynCall('vi', webSocketState.onOpen, [ instanceId ]); for Module['dynCall_vi'](webSocketState.onOpen, instanceId);
Confirmed this fixes the WebGL Runtime error in 2021.2.7f1. There were 5 instances that needed to be updated.
Would be nice to get NativeWebSocket updated with these fixes.
Need this fix Why not merged? :(
I used this code and build finally not fails, but now I'm getting following error when trying to start network game on WebGL: ReferenceError: Runtime is not defined at WebSocket.instance.ws.onopen So, downgrading to Unity 2021.1 :(
Thanks for the PR @kentakang, and everybody that participated! This has been merged, and the Runtime
problem has been fixed, too! Please let me know if you have any issues
NativeWebSocket have an 2 issues in Unity 2021.2
Resolve 2 issues.