Mar
11
2021

Run WebGL server manually

When making webgl builds, you cannot open generated index.html file directly inside the build folder (without webserver), and if you make Build & Run, and then close the browser tab, you need to do build & run again to view it later.

Run webserver from commandline:
"C:/Program Files/Unity2019_4/Editor/Data/MonoBleedingEdge/bin/mono.exe" "C:/Program Files/Unity2019_4/Editor/Data/PlaybackEngines/WebGLSupport/BuildTools/SimpleWebServer.exe" "X:/YourFolder/YourProject/Builds" 60606

* Note the port number as a parameter, other arguments are:
“SimpleWebServer.exe source_directory [port] [pid] [<wasmencoding>]”

** You need to run SimpleWebServer.exe through mono.exe, otherwise it returns “403 forbidden”.

Using UnityLauncherPro:
Just added experimental feature to launch webgl server from project context menu (it launches SimpleWebServer.exe)

Alternatives (web servers) *but requires you to build webgl inside those server folders)
XAMPP, XAMPP Portable, WAMPP, IIS

Alternatives part#2:
– Use ILSpy to decompile SimpleWebServer.exe (its c#), then build it yourself in VisualStudio, now that .exe works normally without needing to run it through mono.exe (and you could customize it to do more things).


1 Comment + Add Comment

Leave a comment

Connect

Twitter View LinkedIn profile Youtube Youtube Join Discord Twitch Instagram

UnityLauncherPro

Get UnityLauncherPRO and work faster with Unity Projects!
*free unity hub alternative

@unitycoder_com

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.