# Single Unity project targeting Android and WebGL builds

**URL:** https://qa.fmod.com/t/single-unity-project-targeting-android-and-webgl-builds/21123
**Category:** Unity
**Created:** [January 19, 2024, 3:18pm UTC](https://qa.fmod.com/t/single-unity-project-targeting-android-and-webgl-builds/21123 "2024-01-19T15:18:42Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![devnull](https://avatars.discourse-cdn.com/v4/letter/d/c89c15/32.png) [@devnull](https://qa.fmod.com/u/devnull)
#### Post date: [January 19, 2024, 3:18pm UTC](https://qa.fmod.com/t/single-unity-project-targeting-android-and-webgl-builds/21123/1 "2024-01-19T15:18:42Z")

</div>

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

---

<div class="post-metadata">

### Author: ![Leah\_FMOD](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/leah_fmod/32/3685_2.png) [@Leah\_FMOD](https://qa.fmod.com/u/Leah_FMOD)
#### Post date: [January 22, 2024, 4:57am UTC](https://qa.fmod.com/t/single-unity-project-targeting-android-and-webgl-builds/21123/2 "2024-01-22T04:57:23Z")

</div>

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](https://www.fmod.com/docs/2.02/unity/settings.html#platform-specific), 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](https://www.fmod.com/docs/2.02/studio/fmod-studio-concepts.html#platforms), 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?

> [@devnull](#):
>
> I tried to built it “as it is” and most of the sfx play without problems, only the music is not playing at all

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?

---

<div class="post-metadata">

### Author: ![devnull](https://avatars.discourse-cdn.com/v4/letter/d/c89c15/32.png) [@devnull](https://qa.fmod.com/u/devnull)
#### Post date: [January 24, 2024, 4:34pm UTC](https://qa.fmod.com/t/single-unity-project-targeting-android-and-webgl-builds/21123/3 "2024-01-24T16:34:19Z")

</div>

Thank you @Leah_FMOD for your answer.

> [@Leah\_FMOD](#):
>
> 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?

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](https://www.fmod.com/docs/2.02/unity/examples-async-loading.html) 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)

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/c/c23c964d8533aed5f400b12b20653c2dcc4c8c28.png)

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](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/1/1ea742c8bb62226b9f5dee9f752273a6f24bf535.png)

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

---

<div class="post-metadata">

### Author: ![Leah\_FMOD](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/leah_fmod/32/3685_2.png) [@Leah\_FMOD](https://qa.fmod.com/u/Leah_FMOD)
#### Post date: [January 25, 2024, 2:36am UTC](https://qa.fmod.com/t/single-unity-project-targeting-android-and-webgl-builds/21123/4 "2024-01-25T02:36:16Z")

</div>

> [@devnull](#):
>
> Is there a better solution?

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](https://github.com/fmod/fmod-for-unity) 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.

---

<div class="post-metadata">

### Author: ![devnull](https://avatars.discourse-cdn.com/v4/letter/d/c89c15/32.png) [@devnull](https://qa.fmod.com/u/devnull)
#### Post date: [January 25, 2024, 2:59pm UTC](https://qa.fmod.com/t/single-unity-project-targeting-android-and-webgl-builds/21123/5 "2024-01-25T14:59:59Z")

</div>

Perfect, thank you @Leah_FMOD for your support

Bye
