WAX Unity Web3 Suite
AnchorLink
AnchorLink
  • Getting Started
  • Installation
    • WebGL installation
  • Examples
    • Quick Start
    • Login
    • Transact (with a Session)
    • Transact (without a Session)
    • Token Transfer
    • Vote
    • Manage CPU/NET
    • Sell Ram
    • Buy Ram
    • Bid Name
  • API Docs
    • AnchorLinkSharp
      • AnchorLink
      • ChannelInfo
      • Defaults
      • IdentifyResult
      • LinkAbiData
      • LinkCallback
      • LinkChannelSession
      • LinkChannelSessionData
      • LinkConstants
      • LinkCreate
      • LinkFallbackSession
      • LinkFallbackSessionData
      • LinkInfo
      • LinkOptions
      • LinkSession
      • LinkSessionDataBase
      • LinkSessionDataConverter
      • LinkSignatureProvider
      • LinkSignatureProviderArgs
      • LinkUtils
      • LoginResult
      • SealedMessage
      • SerializedLinkSession
      • TransactArgs
      • TransactOptions
      • TransactResult
      • WebSocketWrapper
      • Interfaces
        • ILinkOptions
        • ILinkStorage
        • ILinkTransport
      • Exceptions
        • LinkException
        • IdentityException
        • CancelException
        • SessionException
    • EosioSigningRequest
      • AbiConstants
      • CallbackPayload
      • IZlibProvider
      • IdentityV2
      • IdentityV3
      • InfoPair
      • RejectedPayload
      • RequestSignature
      • ResolvedCallback
      • ResolvedSigningRequest
      • SigningRequest
      • SigningRequestAbi
      • SigningRequestConstants
      • SigningRequestCreateArguments
      • SigningRequestCreateIdentityArguments
      • SigningRequestData
      • SigningRequestEncodingOptions
      • TransactionContext
      • TransactionHeader
    • AnchorLinkTransportSharp
      • Transports
        • UnityTransport
        • UnityCanvasTransport
        • UnityUiToolkitTransport
          • ScreenBase
          • PanelBase
          • FailurePanel
          • LoadingPanel
          • QrCodePanel
          • SigningTimerPanel
          • SuccessPanel
          • TimeoutPanel
          • Utils
      • StorageProviders
        • PlayerPrefsStorage
        • JsonLocalStorage
      • TransportOptions
      • NetZlibProvider
Powered by GitBook
On this page
Edit on GitHub
  1. Installation

WebGL installation

PreviousInstallationNextExamples

Last updated 2 years ago

WebGL builds will require the index.html file to be customised.

Download the full customised file .

Ensure that this line is added to make websockets work.

window.unityInstance = unityInstance;
Further reading

WebAssembly for 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) => {
	  
	  // !!! IMPORTANT
	  window.unityInstance = unityInstance; // <-- THIS LINE MUST BE ADDED TO ENSURE WEBSOCKETS WORK!!!
          // !!! IMPORTANT
	  
          loadingBar.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.

window.addEventListener('paste', function (e) {
      const str = e.clipboardData.getData('text');
      window.unityInstance.SendMessage('CanvasExample', 'OnBrowserClipboardPaste', str);
     });
here
security
Page cover image