Unity WebGL Example
Code examples, compatibility guides, and technical documentation for Unity WebGL builds targeting VIVERSE. Includes render pipelines, WebGL templates, loading screens, and deployment examples.
Publishing Tutorial
Anyone can publish their WebGL-compatible Unity project to VIVERSE in a few simple steps. In this guide, we'll walk through the process of creating an new Unity project, making sure it is compatible with WebGL, and publishing to VIVERSE using the VIVERSE CLI.
While VIVERSE is a great place for multiplayer games with networked avatars — and we have a number of services that can help you implement these features — it is not required to implement networked avatars to publish to VIVERSE.
Prerequisites
Unity Hub and Unity installed on your device.
In this tutorial, we will be using Unity v6.1, however any WebGL-compatible version of Unity should be supported.
Step 1. Configure Your Unity Project
Step 2. Build and Publish to VIVERSE
Build Your Project
Navigate to Publish and select "WebGL Publish". In the pop-up, click "Build and Publish", selecting the desired folder for your build. When doing this for the first time, Unity will automatically publish to their web-servers for testing. For future builds, you can disable this behavior to just the builds without publishing.

Test & Configure World Settings
Navigate to the preview url created for the world. You can also access the world and its settings in studio.viverse.com/content.


Submit for Curation and Discovery
By default, worlds uploaded will only be accessible via preview urls. For placement and curation on our webpages, meaning your experience will be easier to share, please submit for review.
Unity & VIVERSE Compatibility Overview
VIVERSE supports Unity WebGL builds with specific requirements and recommendations for optimal performance and compatibility. This section covers essential settings and considerations for targeting VIVERSE.
Supported Unity Versions
VIVERSE supports the following Unity versions:
Unity 2021 LTS (2021.3.x) - Recommended for stability
Unity 2022 LTS (2022.3.x) - Recommended for newer features
Unity 2023.x - Supported, but verify compatibility with VIVERSE SDK
Note: Always use LTS (Long Term Support) versions for production projects targeting VIVERSE to ensure long-term compatibility and support.
Required Unity Modules
Install the following modules via Unity Hub:
WebGL Build Support - Essential for building WebGL projects
WebGL Development Build Support - Recommended for debugging
IL2CPP - Required for WebGL builds (automatically included with WebGL module)
Verify installation: Edit → Preferences → External Tools or check installed modules in Unity Hub.
Supported Render Pipelines
Important: Unity WebGL does NOT support HDRP (High Definition Render Pipeline).
Built-in Render Pipeline:
Fully supported for WebGL/VIVERSE
Best compatibility across all browsers
Recommended for projects targeting maximum compatibility
No additional packages required
Universal Render Pipeline (URP):
Fully supported for WebGL/VIVERSE
Recommended for new projects targeting WebGL
Better performance and modern features optimized for web platforms
Requires URP package (installed via Package Manager)
Optimized for low-end and web platforms
High Definition Render Pipeline (HDRP):
NOT supported on WebGL/VIVERSE
HDRP is designed for high-end GPUs and requires features unavailable in WebGL:
Real-time ray tracing
Advanced volumetrics
Compute shaders with full GPU access
Large render targets
Advanced shader models
WebGL runs in a browser sandbox with restricted GPU access and memory
You must convert HDRP projects to URP for WebGL builds
Choosing a Render Pipeline
For New Projects Targeting WebGL/VIVERSE:
URP is strongly recommended for modern features and optimal WebGL performance
Install via
Window → Package Manager → Unity Registry → Universal RP
For Existing Projects:
Built-in: Works without changes, but URP offers better WebGL performance
URP Migration: Use Unity's Render Pipeline Converter tool (
Edit → Render Pipeline → Universal Render Pipeline → Convert Project to URP)HDRP Projects: Must convert to URP for WebGL builds (HDRP is not supported)
Converting HDRP to URP for WebGL:
Install URP package via Package Manager
Use Unity's Render Pipeline Converter:
Edit → Render Pipeline → Universal Render Pipeline → Convert Project to URP
Review and update materials (HDRP materials need URP equivalents)
Test shaders and lighting (some HDRP features may not have direct URP equivalents)
Optimize for WebGL performance (WebGL is sensitive to draw calls, textures, and shader complexity)
Considerations:
URP provides better WebGL performance than Built-in
URP has smaller build sizes
URP supports modern shader features optimized for web
Built-in has maximum compatibility but lower performance
HDRP cannot be used for WebGL builds
Render Pipeline Settings
Built-in Render Pipeline:
No special configuration needed
Settings in
Edit → Project Settings → GraphicsConfigure Quality Settings as needed
Universal Render Pipeline (URP):
Create URP Asset:
Assets → Create → Rendering → URP AssetAssign in
Edit → Project Settings → Graphics → Scriptable Render Pipeline SettingsConfigure URP Asset settings:
Render Scale: 1.0 (or lower for performance)
HDR: Disabled (WebGL doesn't support HDR)
MSAA: 2x or 4x (balance quality vs performance)
Shadow Distance: Adjust based on your scene needs
Shader Compatibility
Built-in Shaders:
All built-in shaders work with Built-in Render Pipeline
Standard, Unlit, UI shaders fully supported
URP Shaders:
Use URP-compatible shaders (Lit, Unlit, etc.)
Built-in shaders won't work with URP
Convert shaders using Shader Graph or manually rewrite
HDRP shaders are NOT compatible - must convert to URP shaders for WebGL
Custom Shaders:
Ensure shaders are compatible with your chosen render pipeline
HDRP shaders cannot be used in WebGL builds - convert to URP equivalents
Test shaders in WebGL build (some features may not work)
WebGL 2.0 supports most modern shader features, but not HDRP-specific features
WebGL is sensitive to shader complexity - optimize for performance
Unity Formatting and Custom Loading Screens
An example of a fullscreen webgl template can be found here. The instructions for creating a webgl fullscreen template are below.
Understanding WebGL Templates
WebGL templates control the HTML/CSS/JavaScript wrapper around your Unity WebGL build. They determine:
How the canvas is displayed (fullscreen, windowed, etc.)
Loading screen appearance and behavior
Browser UI elements visibility
Mobile responsiveness
Fullscreen functionality
Default Templates:
Unity provides default templates (Minimal, Default, etc.)
Custom templates allow full control over presentation
Fullscreen Canvas Benefits
A fullscreen canvas template provides:
Immersive Experience: No browser UI distractions
Maximum Screen Usage: Canvas fills entire viewport
Better Performance: No layout calculations for browser elements
Professional Appearance: Clean, game-like presentation
VIVERSE Optimization: Matches VIVERSE's immersive environment
Key Features:
Canvas set to 100% width and height
Body and container with
overflow: hiddenNo scrollbars or browser chrome
Responsive to different screen sizes
Mobile-friendly viewport configuration
Custom Loading Screen Overview
Custom loading screens enhance user experience by:
Branding: Display your logo/branding during load
Progress Feedback: Show loading progress to users
Professional Appearance: Custom design matching your project
User Engagement: Keep users informed during asset loading
Components:
Loading bar container (centered on screen)
Logo/branding element
Progress bar (animates from 0% to 100%)
Optional loading text or animations
Styled with CSS for custom appearance
Step 1. Create the WebGL Template Folder Structure
Step 2. Create the Fullscreen HTML Template
Add Fullscreen HTML Structure
Open index.html and add the following fullscreen template code:
Key Features:
bodyand#unity-containerset to 100% width/height withoverflow: hiddenfor true fullscreenCanvas fills entire viewport (
width: 100%,height: 100%)Loading bar centered on screen during asset loading
Footer hidden by default (can be shown if needed)
Mobile-responsive viewport meta tag
Step 3. Customize the Loading Screen
Understanding the Loading Screen Elements
The template includes several customizable elements:
#unity-loading-bar: Container for loading screen elements#unity-logo: Logo image displayed during loading#unity-progress-bar-empty: Background of the progress bar#unity-progress-bar-full: Animated progress bar that fills from 0% to 100%
All elements are centered on screen using CSS transforms.
Replace Default Loading Images
In the
FullScreenfolder, replace the default Unity loading images with your custom assets:unity-logo-dark.png(154×130px recommended) - Your logo/brandingprogress-bar-empty-dark.png(141×18px) - Progress bar backgroundprogress-bar-full-dark.png(141×18px) - Progress bar fill image
Alternatively, modify the CSS in
index.htmlto use different image paths or create custom loading UI with HTML/CSS instead of images.
Step 4. Configure Build Settings
Configure Additional WebGL Settings
For optimal VIVERSE deployment, configure these settings:
Resolution and Presentation:
Default Canvas Width: 1920 (or your target resolution)
Default Canvas Height: 1080 (or your target resolution)
Run In Background: Enabled (recommended for VIVERSE)
Publishing Settings:
Compression Format: Gzip or Brotli (for smaller file sizes)
Data caching: Enabled (improves load times for returning users)
Name Files As Hashes: Enabled (better caching)
Other Settings:
Strip Engine Code: Enabled (reduces build size)
Managed Stripping Level: Medium or High (further reduces size)
Step 5. Build the WebGL Project
Verify Build Output
Your build folder should contain:
index.html- Your custom fullscreen templateBuild/folder - Contains Unity WebGL build files (.data, .framework.js, .loader.js, etc.)TemplateData/folder (if using default template) - Contains template assetsStreamingAssets/folder (if you have streaming assets) - Contains additional assets
The index.html should be your custom fullscreen template with the loading screen.
Step 6. Test the Fullscreen Build Locally
Set Up Local Server
WebGL builds require a web server to run (cannot open index.html directly due to CORS restrictions).
Option 1: Python HTTP Server (if Python installed):
Then open http://localhost:8000 in your browser.
Option 2: Node.js HTTP Server:
Option 3: Unity's Built-in Server: After building, Unity may offer to open a local server automatically.
Test Fullscreen Functionality
Open the build in your browser
Verify the loading screen appears and progress bar animates
Once loaded, the canvas should fill the entire browser window
Test the fullscreen button (if visible) or press
F11for browser fullscreenVerify no browser UI elements are visible (address bar, scrollbars, etc.)
Test on different screen resolutions and aspect ratios
Step 7. Deploy to VIVERSE
Prepare Build for Upload
Navigate to your build output folder
Select all files and folders (
index.html,Build/,StreamingAssets/if present)Create a ZIP archive of these files
Name it appropriately (e.g.,
MyProject_WebGL_Build.zip)Verify the ZIP contains the root
index.htmlfile (not nested in a subfolder)
Step 8. Advanced Customization
Optimize Loading Performance
Enable Compression: In Player Settings → Publishing Settings, use Gzip or Brotli compression
Reduce Build Size: Enable code stripping and remove unused assets
Use Addressables: For large projects, consider Unity Addressables for on-demand loading
Optimize Assets: Compress textures, reduce polygon counts, optimize audio files
CDN Hosting: Host your build on a CDN for faster global loading times
Troubleshooting
Template Not Appearing in Build Settings:
Ensure the folder is named exactly
WebGLTemplates(case-sensitive)Ensure
index.htmlis directly in the template folder (e.g.,Assets/WebGLTemplates/FullScreen/index.html)Refresh Unity project (
Ctrl+R/Cmd+R)Restart Unity Editor
Loading Screen Not Showing:
Check browser console for JavaScript errors (
F12)Verify image paths in CSS are correct
Ensure
loadingBar.style.display = "block"is called before Unity loadsCheck that progress callback is properly connected
Fullscreen Not Working:
Verify canvas CSS has
width: 100%andheight: 100%Check that
bodyand container haveoverflow: hiddenTest in different browsers (Chrome, Firefox, Edge)
Some browsers require user interaction before allowing fullscreen API
Build Too Large:
Enable compression in Publishing Settings
Increase Managed Stripping Level
Remove unused assets and scripts
Consider using Unity Addressables for large content
Compress textures and audio files
VIVERSE Upload Issues:
Ensure ZIP contains
index.htmlat root levelVerify all required files are included (Build folder, etc.)
Check file size limits in VIVERSE Studio
Ensure WebGL build target is correct (not IL2CPP if not supported)
Last updated
Was this helpful?






