Important! waxjs.js needs to be included in your build, next to the customised html file and needs to be loaded by your html file. Download waxjs.js here
Ensure that this line is added to make websockets work.
window.unityInstance = unityInstance;
Further reading
WebAssembly for security purposes does not have Networking-Capabilities.
Read more here: (https://webassembly.org/docs/security/)
Final script should have this included
script.onload= () => {createUnityInstance(canvas, config, (progress) => {progressBarFull.style.width =100* progress +"%"; }).then((unityInstance) => {// !!! IMPORTANTwindow.unityInstance = unityInstance; // <-- THIS LINE MUST BE ADDED TO ENSURE WEBSOCKETS WORK!!!// !!! IMPORTANTloadingBar.style.display ="none";fullscreenButton.onclick= () => {unityInstance.SetFullscreen(1); }; }).catch((message) => {alert(message); });
Additional snippets
Unity WebGL requires an event listener to paste from the OS clipboard. Use the following structure in script.onload.
// !!!// !!! adding this Listener allows to copy-paste date from outside the WebGL-Build into the WebGL-Buildwindow.addEventListener('paste',function (e) {conststr=e.clipboardData.getData('text');// Calls Method OnBrowserClipboardPaste in class WaxCloudWalletMainPanel while passing str as argumentwindow.unityInstance.SendMessage('WaxCloudWalletMainPanel','OnBrowserClipboardPaste', str); });// !!! });