Single Unity project targeting Android and WebGL builds

Hi everyone,
the project I’m working on started as Android only (with a FMOD project in it) but from now on it will need to support WebGL as well.
I tried to built it “as it is” and most of the sfx play without problems, only the music is not playing at all.
Given that WebGL need some setup/adjustment (being singlethreaded), I would like to know if is it possible to keep both the Android version (with full fledged FMOD functionality) and the WebGL one (with the adjusted functionality) in the same Unity project (and also in the same relative FMOD project).

Thanks for the help

Bye

Hi,

It would depend on exactly what needs to be changed between platforms, but it should be possible, yes. The FMOD for Unity integration allows you to set platform-specific settings, including platform specific callbacks that you can use to hook into the initialization process and customize it to your needs. FMOD Studio also allows you to set platform-specific settings, which among other things will allow you to exclude effects and event audio tracks on specific platforms, set custom per platform encoding settings for assets, etc.

Do you have any specific functionality that you only want on WebGL in mind?

Do you receive any warnings from FMOD? What encoding settings (if any) are being used for your music assets, and are they set to stream?

Thank you @Louis_FMOD for your answer.

At first were set to stream, but after re-reading the docs and some threads here in the forum I:

  1. unchecked the stream option in the FMOD project
  2. change the DSP buffer to an higher value (2048, I hope it’s a reasonable value) in the FMOD Settings inside the Unity Editor
  3. Set Load Banks option to None in the FMOD Settings inside the Unity Editor and loaded them at runtime (in the first scene, the project has multiple consecutive scenes) using this script here in the docs

after those steps everything went ok.

But now I’ve got another problem. As it is now, this is working fine if I start the game from the first scene (like in the production mobile and webgl builds) but not If I need to start another sigle scene/level from the Unity Editor because Load Banks cannot be choose per platform but is global (if I’m not mistaken)

What I did to solve was not exactly the best but it’s working:

  1. Duplicated the Assets/Plugins/FMOD/Resources/FMODStudioSettings.asset in Assets/Plugins/FMOD/Resources/FMODStudioSettingsWebGL.asset
    image

  2. edited the Assets/Plugins/FMOD/src/Settings.cs file like this

Blockquote
#if UNITY_WEBGL
internal const string SettingsAssetName = “FMODStudioSettingsWebGL”;
#else
internal const string SettingsAssetName = “FMODStudioSettings”;
#endif

  1. Set Load Banks to All in FMODStudioSettings
  2. Set Load Banks to None in FMODStudioSettingsWebGL

So the audio in the Editor and in the Android build is now working as it was before, meanwhile the WebGL build has its own complete separate settings.

The problem with this is that everytime that I upgrade the FMOD Unity plugin I potentially need to re-add my changes in Assets/Plugins/FMOD/src/Settings.cs.

Is there a better solution?
I know that I can maybe use an Additive Scene only for audio but with the current state in which my Unity project is that’s a bit overkill.

Thank you again for the help

Bye

Most solutions will probably involve using conditional compilation as you’ve done, so if your solution appropriately addresses your use-case, then I’d say it’s fine. As for upgrading the plugin, you can grab the plugin code (without FMOD libs) directly from the fmod-for-unity github repo.

That said, I can definitely see how this area of the plugin’s per-platform settings are lacking, so I’ll note this on our internal feature/improvement tracker.

Perfect, thank you @Leah_FMOD for your support

Bye