floatinghotpot / socket.io-unity

socket.io client for Unity, power game client with node.js back-end
494 stars 75 forks source link

Work with WebGL? #42

Open Zeon8 opened 5 years ago

Zeon8 commented 5 years ago

It work in editor, but when i build WebGL not work no errors no warnings no connecting logs

PredragSilj98 commented 4 years ago

You need to use some workaround. It's no problem with this plugin, but the way unity builds WebGL.

Check this link: https://docs.unity3d.com/Manual/webgl-interactingwithbrowserscripting.html

Basically, when you build your WebGL app, inside that index.html add socketi.io client (you can use from their website). And from c# call function in the browser (make some foo() function) that will init stuff like wich events to call from javascript to c#).

Inside c# just remap functionality to use external DLL import (you don't need socket.io plugin inside unity).

Sadly I don't have an example to show as I did this for the company.