I created asset bundles (using Asset Bundle Browser) for WebGL and 20mb audios became 70mb asset bundles. When I did the same for Android and iOS the assets were less, 13mb. Did I miss some important config in the project’s settings? Can I at least have audio same size as original?
Also, I am getting error when I am trying to play audio loaded from WebGL asset bundle in Editor but Android/iOS assets bundles were working fine. Is this a limitation for WebGL asset bundles and is there any workaround so I can keep testing app in editor? (since building WebGL project takes 7 min)
I found the answer: Unity WebGL does not support client side MP3 decoding, so they have to convert audio to wav, which causes the bundles to get bigger. At first I thought to use a native HTML5 via JS plugin but later membered that Chrome/Firefox does not support MP3 playback =(
So the question about playing audio in Editor to debug app remains open.
p.s. Why Unity is not allowing us to use OGG for some audios? That will be at least 3 times smaller asset bundles.
Good to know as I haven’t tried it per se but my advice is to report your findings in the 2021.2 beta forum + attach a bug report case. I am certain you’ll get more answers from devs there.
@KamilCSPS I believe it will be a wasting of time (it’s not high demanded feature). I personally found building WebGL build for 7 minutes pretty annoying. So, it should be easier to make PostProcessBuild script which will copy Android’s bundles to StreamingAssets folder (which works in Editor) when I click Play button in Editor and WebGL budnles when I click build button. I know how to handle build but I am not sure how to play in Editor. Perhaps it’s the same code which needs just a platfrom dependent compilation.
Hi Andrew,
We have found that at the same quality setting, WebGL asset bundles are about 60% bigger at the same quality setting as the iOS and Android asset bundles in terms of audio size, in 2020.3. So audio compressing much better for iOS and Android. We’ve had to lower quality to 1 for many audio files, which did not affect quality much but reduced files sizes significantly. The whole process of setting a vague quality rather than an exact bitrate seems strange, we’ve had to live with it.
As you mentioned, Unity is expanding and recompressing audio, so we realized no benefit to compressing the source files: may as well use originals or lightly compressed. Easy for files to get BIGGER than source like you saw, if Quality 1 is higher bitrate than your source.
That’s interesting. Could you please tell us, where did you change that? We usually change the quality of the source audio but if there is an option to set audio quality within Unity, that should help a lot! Thank you in advance!