Unity/Fmod: Adaptive Music in WebGL

Hey everyone!

I was looking through the manual, but couldn’t find my answer there specifically, so figured I’d ask here:

I’m trying to set up a super simple adaptive music demo for pitches and generally showcasing adaptive music at lectures. Very simple, just a Unity project with a play button, and a couple of buttons for parameter/intensity changes that trigger transitions.

When I build to Mac/Windows, the app works flawlessly, but when building and testing in WebGL, I get zero response from the state/parameter changes. The play button works, but nothing else. When I change the build settings to WebGL, it still works great in Unity, but the problems arise when testing the build locally in the browser.

Is there anything I can do about this, or is this the limitation of WebGL today?

Hi,

The issue is WebGL is single-threaded so it cannot load banks in the same manner you would use on other platforms.

We have an example script to asynchronously load banks and then trigger a scene load which can then play events: FMOD Studio | Scripting Examples - Asynchronous Loading.

We also have a full Unity HTML5 demo on our GitHub: GitHub - fmod/unity-html5-demo: Demonstration of the correct way to load banks for HTML5 within Unity using the FMOD For Unity integration. this displays using a loading scene with the script.

Hope this helps!

Hi Connor! Thank you! I just checked out the demo project, and that one works nicely. Thanks for sending that!

The project has no instances of “StudioParameterTrigger” I’m trying to get working in WebGL - just moving the playhead from one clip to the next in Fmod :slight_smile: Is this possible in WebGL?

Yes, it is possible.
There are two options, setting the parameter on the emitter or using a FMOD Studio Parameter Trigger:


Unity Integration | Game Components - Studio Event Emitter
Unity Integration | Game Components - Studio Parameter Trigger

Hope this helps!