The WebGL memory size field in Publishing Settings lets you specifiy how much memory (in MB) the content should allocate for it’s heap.
If you enable Stripping, Unity will not include code for any classes you don’t use - so if you don’t use any physics components or methods for instance, the whole physics engine will be stripped from your build. Note that WebGL does not differentiate between different stripping levels, it is either enabled or not. The Strip Engine Code option in Other Settings lets you enable code stripping for WebGL. WebGL has some additional options in the Player Settings (menu: Edit > Project Settings > Player). It is not possible to connect the Profiler to a running build like on other platforms, as the profiler connection is handled using WebSockets on WebGL, but the browser will only allow outgoing connections from the content, so the only way to use the Profiler in WebGL is to check “Autoconnect Profiler” to have the content connect to the Editor. The “Autoconnect Profiler” checkbox must be used when you want to profile your Unity WebGL content. Additionally, Development builds are non-minified, so the generated JavaScript is human-readable and preserves function names (so you will get useful stack traces for errors), but very large to distribute. When you tick the “Development Build” checkbox, Unity will generate a development build (with Profiler support and the development console for errors, like on other platforms). “Fast” produces optimized builds, and “Fastest” enables some additional optimizations, but makes your builds take a long time to complete (so you might want to use it only for final releases). In general, “Slow” produces unoptimized builds, but has much lower build times then the other options, so it can be used for iterating on code issues. These correspond to optimization flags (-O1 -O3) passed to the emscripten compiler. WebGL allows you to select an Optimization level in the Build Player window.
If you use Unity’s Build & Run command (menu: File > Build & Run) then the file will be temporarily hosted in a local web server and opened from a localhost URL (this avoids the security restrictions).Ĭurrently, the Firefox and Chrome browsers are known to support Unity WebGL players. For safety/security reasons, most other browsers place restrictions on scripts opened from local file: URLs, so this technique will not work. You can view your WebGL player directly in the Firefox browser by simply opening the index.html file. some supporting JavaScript files to initialize and load the player.data file containing the asset data and scenes. mem file containing a binary image to initialize the heap memory for your player. a JavaScript file containing the code for your player.
an index.html file that embeds your content in a web page.When you build a WebGL project, Unity will create a folder with the following files: