Unable to build: Settings instance has not been initialized. Unable to continue build

With Unity 2021.3.16 (and 2021.3.15) I get this error when opening an project with just FMOD imported into it:

Settings instance has not been initialized. Unable to continue build.
UnityEngine.Debug:LogWarning (object)
FMODUnity.RuntimeUtils:DebugLogWarning (string) (at Assets/Plugins/FMOD/src/RuntimeUtils.cs:558)
FMODUnity.EditorSettings:CheckActiveBuildTarget () (at Assets/Plugins/FMOD/src/Editor/EditorSettings.cs:664)
FMODUnity.Settings:OnEnable () (at Assets/Plugins/FMOD/src/Settings.cs:622)
UnityEngine.Resources:Load (string)
FMODUnity.Settings:Initialize () (at Assets/Plugins/FMOD/src/Settings.cs:267)
FMODUnity.EditorUtils:CallStartupMethodsWhenReady () (at Assets/Plugins/FMOD/src/Editor/EditorUtils.cs:439)
UnityEditor.EditorApplication:Internal_CallUpdateFunctions () (at /Users/bokken/build/output/unity/unity/Editor/Mono/EditorApplication.cs:356)

This also breaks our builds on our build machine most of the time which is obviously really frustrating!

I’ve tried to diagnose why this is happening, currently my best conclusion is that this is caused by trying to call Resources.Load on something that is currently in the process of being loaded (i.e. from OnEnable). This happens because CanBuildTarget fails if Settings.Instance is null.

Steps to reproduce:

  • Import fmodstudio20211.unitypackage into an empty Unity project
  • Notice the errors
  • Restart Unity
  • Notice the errors

The builds have failing fail with the same error but a variety of call stacks, but this doesn’t appear to be reproducible from an empty project (even with an FMOD bank setup).

BuildFailedException: Settings instance has not been initialized. Unable to continue build.
  at FMODUnity.EditorSettings+BuildProcessor.OnPreprocessBuild (UnityEditor.Build.Reporting.BuildReport report) [0x00054] in /Users/build/buildAgent/work/99ab41247e8a53b7_Android/Assets/Plugins/FMOD/src/Editor/EditorSettings.cs:641
  at UnityEditor.Build.BuildPipelineInterfaces+<>c__DisplayClass16_0.<OnBuildPreProcess>b__1 (UnityEditor.Build.IPreprocessBuildWithReport bpp) [0x00000] in /Users/bokken/build/output/unity/unity/Editor/Mono/BuildPipeline/BuildPipelineInterfaces.cs:436
  at UnityEditor.Build.BuildPipelineInterfaces.InvokeCallbackInterfacesPair[T1,T2] (System.Collections.Generic.List`1[T] oneInterfaces, System.Action`1[T] invocationOne, System.Collections.Generic.List`1[T] twoInterfaces, System.Action`1[T] invocationTwo, System.Boolean exitOnFailure) [0x000ff] in /Users/bokken/build/output/unity/unity/Editor/Mono/BuildPipeline/BuildPipelineInterfaces.cs:402
UnityEngine.DebugLogHandler:Internal_LogException(Exception, Object)
UnityEngine.DebugLogHandler:LogException(Exception, Object)
UnityEngine.Logger:LogException(Exception, Object)
UnityEngine.Debug:LogException(Exception)
UnityEditor.Build.BuildPipelineInterfaces:InvokeCallbackInterfacesPair(List`1, Action`1, List`1, Action`1, Boolean) (at /Users/bokken/build/output/unity/unity/Editor/Mono/BuildPipeline/BuildPipelineInterfaces.cs:415)
UnityEditor.Build.BuildPipelineInterfaces:OnBuildPreProcess(BuildReport) (at /Users/bokken/build/output/unity/unity/Editor/Mono/BuildPipeline/BuildPipelineInterfaces.cs:434)
UnityEditor.BuildPipeline:BuildPlayerInternalNoCheck(String[], String, String, BuildTargetGroup, BuildTarget, Int32, BuildOptions, String[], Boolean)
UnityEditor.BuildPipeline:BuildPlayerInternal(String[], String, String, BuildTargetGroup, BuildTarget, Int32, BuildOptions, String[]) (at /Users/bokken/build/output/unity/unity/Editor/Mono/BuildPipeline.bindings.cs:449)
UnityEditor.BuildPipeline:BuildPlayer(String[], String, String, BuildTargetGroup, BuildTarget, Int32, BuildOptions, String[]) (at /Users/bokken/build/output/unity/unity/Editor/Mono/BuildPipeline.bindings.cs:348)
UnityEditor.BuildPipeline:BuildPlayer(BuildPlayerOptions) (at /Users/bokken/build/output/unity/unity/Editor/Mono/BuildPipeline.bindings.cs:322)
UnityEditor.BuildPipeline:BuildPlayer(String[], String, BuildTarget, BuildOptions) (at /Users/bokken/build/output/unity/unity/Editor/Mono/BuildPipeline.bindings.cs:317)
AndroidBuild:Build(String, String, Int32, Boolean, Boolean, Boolean, Boolean) (at Assets/Scripts/Editor/Build/AndroidBuild.cs:109)
BuildSystem:BuildGame(BuildFormFactor) (at Assets/Scripts/Editor/Build/BuildSystem.cs:55)
BuildSystem:BuildFromEnvironmentVariables() (at Assets/Scripts/Editor/Build/BuildSystem.cs:23)

I’m having the same problem in the post

1 Like

Try to remove the Unity FMOD package and install version 2.01.11 by downloading directly from the FMOD Downloads website.

1 Like

There is an issue in FMOD for sure. I updated FMOD (don’t know what version I had before) but now with 2.02.11 I got this same issue: ‘Unable to build: Settings instance has not been initialized. Unable to continue build’
I am working on 2021 LTS, even updated it to the latest version. And downloaded the latest version from the FMOD website in the hope it fixes it.

However, upon closer inspection of the code, I found a bug in the code. That causes this issue.
On application start, EditorUtils line 439 gets hit. In this, it guards the instance until its loaded (and for the time being returns null). As a part of the loading it gets a setting resource.
This setting is a ScriptableObject resource, and on the end of its OnEnable, it does a fatal call:
Settings.cs line 622 ‘EditorSettings.CheckActiveBuildTargets()’. You can’t call this, because it relies on the settings instance being loaded, but at this moment the Settings instance is still loading and guarded and thus null.

So, to fix this, comment out line 622 of FMOD/src/Settings.cs

The following isn’t neccecarily needed, but It keeps the original code flow working. With this it gets called when the settings ARE initialized.
Go to FMOD/src/Editor/EditorUtils.cs and paste the following after line 439 ‘Settings.Initialize();’

#if UNITY_EDITOR
Settings.EditorSettings.CheckActiveBuildTarget();
#endif

3 Likes

Hi,

You are correct, this is a known issue. Thank you for providing a workaround, I will pass it on to our development team to look into further.

Thanks again!

5 Likes

Thank you so much! This worked like charm

1 Like

Ahh amazing, thank you so much for looking into this! This fixed my pipeline :smiley:

Is/will this be addressed, and if so, when and how will i know? Seems rather significant. also, thanks for the fix erik.

Shouldn’t the Unity verified program catch issues like this? Every time I’ve updated fmod to a verified version it has broken the game in some way. Last time it just got stuck in a loop continuously updating banks, this time it is this! I do like using fmod but the integration seems to be the worst out of any plugin that we use.

Thanks to everyone for their feedback and the provided fix, this will be addressed for our next release. For those comfortable with modifying our scripts the response from @erikdrsoftware above is the same solution we will use in the release. For those who would prefer to wait, our next release will include the fix, it’s currently scheduled for next week, you can subscribe to our release newsletter to be notified when it goes live.

To the question of whether this issue should have been caught, the answer is always ideally yes, but in reality, things do get missed. In this case, this issue managed to go unnoticed as an innocuous warning. For the case of loading into the editor, the CanBuildTarget check is skipped (not ideal) but ultimately things are still working and are usable. In the case of building from a script, this will prevent the completion of the build. This highlights a lack of testing for this scenario that will be addressed both within our QA team and as feedback that is passed onto the Verified Solutions team at Unity.

If anyone is still stuck by this after applying the fix or there are follow on issues, please let us know so we can make sure our next release is solid. Thanks for your patience.

Thanks for the response @mathew - glad to hear it’s taken seriously. I know it’s difficult to test things fully, but you’d obviously hope that Unity’s verified program would be experts at this and know all the test cases worth testing. Thanks again.

As a quick addendum to this, I’ve received word back from Unity, they have acknowledged this issue and will include such tests in future verification work.

1 Like

Hello,

I’m completely new to Unity and FMOD and I’m getting this error. I’m running through the FMOD integration tutorial and am up to importing FMOD for Unity. When I import only some of the assets are selected rather than all of them like the tutorial. If I click the select all button it doesn’t work… Feeling a bit stuck…

thank you so much for this!! you saved my night :slight_smile:

Hi,

Could you link to the step you are currently on in the tutorial?