Skip to content

WebGL Publishing

WebGL builds allow you to run your Digital Twin directly in web browsers without any installation. This enables easy sharing and access through URLs, making it ideal for demonstrations and client presentations.

WebGL build needs to be done with IL2CPP, and Windows DLLs which are used in some interfaces can’t be used (only way to communicate from a browser is Websocket).

For building WebGL, you need to delete the following folders if they are in your project:

  • CADLink
  • SpaceNavigator
  • All Interfaces (besides MQTT and TwinCATHMI - these both are the only ones which are possible with WebGL)
  • parts4cad
  • RobotIK

Set WebGL in Build Settings:

Setting WebGL in Build Settings

Make sure that in Player Settings Scripting Define Symbols you have the same settings as for Windows (e.g., GAME4AUTOMATION and GAME4AUTOMATION_PROFESSIONAL).

Disable Auto Graphics API in Player Settings to use exclusively WebGL2 (recommended):

WebGL2 Graphics API configuration

In Publishing Settings set Decompression Fallback - this prevents problems with some web servers.

Decompression Fallback setting

  1. Open File > Build Settings
  2. Select WebGL as the target platform
  3. Configure Player Settings as described above
  4. Click Build and choose your destination folder
  5. Wait for the build to complete (this may take 30-60 minutes)
  6. Unity will automatically start a local web server and open your browser

Enhance your Unity WebGL projects with the realvirtual WebGL Template, offering a full-screen, responsive design for an improved user experience compared to the standard Unity WebGL Template.

  1. Locate Template Files: Find the template files in your Unity project at:

    Terminal window
    Assets/realvirtual/Professional/WebGLTemplate/realvirtual
  2. Copy Template Files: Copy these files.

  3. Paste into WebGLTemplates: Paste the copied files into:

    Terminal window
    Assets/WebGLTemplates/realvirtual
  1. Open Unity.
  2. Go to Edit > Project Settings.
  3. In Player settings, find Resolution and Presentation.
  4. Choose the realvirtual template from the “Template” dropdown menu.
  5. Save your changes.

realvirtual WebGL Template selection

To deploy your WebGL build:

  1. Copy the entire build folder contents to your web server
  2. Ensure your web server supports:
    • Proper MIME types for Unity files
    • Compression (gzip or Brotli)
    • HTTPS (recommended for full functionality)
  • Apache: Add .htaccess with proper MIME types
  • nginx: Configure mime.types for Unity file extensions
  • IIS: Add MIME types in web.config
  • Cloud platforms: AWS S3, Azure Static Web Apps, GitHub Pages

WebGL builds have limited interface support due to browser security restrictions:

Supported Interfaces:

  • MQTT (Pro) - Websocket-based messaging
  • TwinCAT HMI (Pro) - Websocket-based communication

Not Supported:

  • OPC-UA
  • S7 TCP/IP
  • Modbus
  • TwinCAT ADS
  • Shared Memory
  • Any Windows DLL-based interfaces

For full interface compatibility, use Windows builds.

  • Build Time: First builds can take 30-60 minutes
  • File Size: WebGL builds are typically larger than native builds
  • Runtime Performance: 60-70% of native performance is typical
  • Memory: Browser memory limitations apply
  • Mobile: Limited support on mobile browsers

Recommended browsers:

  • Chrome/Edge (Chromium-based) - Best performance
  • Firefox - Good compatibility
  • Safari - Basic support (may have limitations)
  • Ensure all incompatible folders are deleted
  • Check that IL2CPP is selected as scripting backend
  • Verify WebGL module is installed in Unity Hub
  • Check web server MIME type configuration
  • Verify compression settings match build settings
  • Ensure HTTPS is enabled if using certain features
  • Reduce scene complexity
  • Use texture compression
  • Optimize draw calls
  • Consider quality settings for WebGL

© 2025 realvirtual GmbH https://realvirtual.io - All rights reserved.