Search code examples
unity-game-enginebuildconfigurationunity-webgl

Unity WebGL Build size increased with version upgrade (2018.4)


My Unity project builds to about 16MB for WebGL. I have a build script that enforces settings such as build size, compression, included scenes (we use asset bundling), and more.

When switching from 2018.2 to 2018.4 my build size went from 16MB to 40MB. I have double checked all the build settings, scene inclusion and asset bundle settings. Everything is the same.

I cannot find any reason why it would be so large, or any related issues on the forums / questions. Any ideas of where to start? Happy to provide settings in full if that would help.

I tried on both a windows and mac with same results.


Solution

  • The issue was the introduction of nested prefabs between 2018.2 and 2018.4. I had a build script that removed my theme song audio files from a prefab on my first scene, so that it could be loaded from an asset bundle on webgl. On 2018.2 the prefab auto saved and this was fine, the audio files were taken out of the build so it only existed in the asset bundle, on 2018.4 however you have to manually save the prefab, so the large audio files existed in the build as well as my asset bundle.

    note: for those curious, i dont use asset bundles for iOS or Android so thats why i leave the audio files in the first scene. I have a custom webgl build script