Unity Integration 2.03
FMOD for Unity supports the use of OBB expansion files on Android.
Loading banks from the expansion files is an asynchronous operation and needs to be done ahead of time. You will need to check that the banks have been loaded before trying to play events from them, see Async Loading for more information.
Any platform specific requirements for Android also apply to Android-based VR devices, such as Oculus Quest.
The Debug Overlay will only work with the Universal Render Pipeline.
As it supports The Universal Additional Camera Data Component which allows the overlay to be drawn correctly. You will need to add:
UNITY_URP_EXIST to the player settings.fmodOverlayLayer.If these requirements are not met the overlay will not be drawn and the corresponding errors will be logged in the console.
Multi pass stereo mode doesn't support Camera Stacking. Overlay cameras will skip rendering.XR Plug-in Management -> Oculus settings. Make sure that the Stereo Rendering Mode is set to Multi View.To record microhpone input on iOS you will need to manually enable the AVAudioSessionCategoryPlayAndRecord category on the AVAudioSession in the built Xcode project. You can do this by adding the following lines to the UnityAppController.mm file inside the startUnity method:
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayAndRecord error:nil];
[[AVAudioSession sharedInstance] setActive:YES error:nil];
You will also need to add a "Privacy - Microphone Usage Description" (NSMicrophoneUsageDescription) key to the built project's Info.plist file, with a string value explaining to the user how your application will use their recorded data.
The following platforms require banks to be loaded asynchronously before you are able to use them:
- HTML5/WebGL
- Android when using expansion files
When loading banks, if FMOD.Studio.System.getEvent is called before the bank has finished loading, you will get FMOD.Result.ERR_EVENT_NOTFOUND.
To avoid this, make use of the functions FMODUnity.RuntimeManager.HasBankLoaded (this function takes the name of a bank minus the .bank extension) or FMODUnity.RuntimeManager.HaveAllBanksLoaded. For example:
if (FMODUnity.RuntimeManager.HasBankLoaded("Master Bank"))
{
Debug.Log("Master Bank Loaded");
SceneManager.LoadScene(sceneName, LoadSceneMode.Single);
}
See the Async Loading Example for a scripting example of loading the FMOD banks in a loading scene before transitioning to the next scene.
Platforms such as iOS, tvOS, Switch, and Switch 2 make use of statically linked FMOD libraries. FMOD for Unity will select the logging or release version of these libraries at build time, based on the Development Build setting.
On iOS and tvOS, FMOD for Unity will select the simulator version of the libraries if the Target SDK is set to Simulator SDK.
Static platforms do not support dynamic loading, so any FMOD plugins must be statically linked into the executable. See Static Plugins for details.
The WebGL platform is only supported by the FMOD for Unity plugin in Unity 2019.1 and newer.
Support for WebGL is included with the base integration, so no additional installation is required. The libraries for WebGL are found in the "\Assets\Plugins\FMOD\platforms\html5\lib" Folder of your project. If using Unity 2021.2.0f1 or later, the libraries in the "2.01.19" subdirectory will be used instead. For the version of FMOD that logs more information to the console, use "libfmodstudiounitypluginL.bc" or "2.0.19\libfmodstudioL.a". This can be useful when debugging and will give more verbose warnings/errors.
Banks load from the "\Assets\StreamingAssets" folder, just as they do on other platforms. FMOD Banks are not packed into the Unity package, this gives more flexibility.
Loading banks from the StreamingAssets folder is an asynchronous operation and you will need to check that any banks you want to use are loaded before you try to access them. See Async Loading
The FMOD Unity bouncing ball example uses a loading screen that checks that the bank has loaded, before moving onto the next scene.
All banks can be checked if they have loaded, but only the last bank loaded needs to be checked, as they are loaded in order and checking the last bank will confirm that all banks have loaded.
Remember that HTML5 does not support threads. If there is stuttering audio it is a good idea to check the game's update rate, to make sure that the sound is mixed in time before the next frame operates. If the game framerate is too slow, or has large pauses, there may be stuttering audio.
The buffer size for FMOD can be increased, which will incur larger audio latency, but handle larger delays between audio mixing. To adjust buffer size use the WebGL specific setting in the Unity plugin FMOD menu under Edit Settings.
What about the asynchronous bank loading? This is a Unity wrapper feature. It uses a Coroutine to load over the web, using the built in UnityEngine.Networking.UnityWebRequest feature.
Most browsers have a user interaction requirement, or audio will not be audible, see the API documentation for further details.
FMOD output will become audible upon detecting a user interaction.
Go to FMOD Unity bouncing ball example for a runtime example of FMOD for WebGL in Unity.
To download the Unity package with the project and source data, go to the FMOD HTML5 Demo page on the FMOD GitHub page.