fmod

FMOD: Cleaning up duplicate platform warning


FMOD for Unity 2.01.07 (Unity 2019.4.18f1 - running on MacOS Catalina) seems to have broken their FMODStudioSettings class.

I can't save in the editor without getting these errors:

FMOD: Cleaning up duplicate platform: ID  = playInEditor, name = 'Play In Editor Settings', type = PlatformPlayInEditor
ArgumentException: An item with the same key has already been added. Key: playInEditor
FMOD: Cleaning up duplicate platform: ID  = default, name = 'Default Settings', type = PlatformDefault
ArgumentException: An item with the same key has already been added. Key: default
NullReferenceException: Object reference not set to an instance of an object
FMODUnity.SettingsEditor.DisplayPlugins (System.String title, FMODUnity.Platform platform, FMODUnity.Platform+PropertyAccessor`1[T] property, System.Collections.Generic.Dictionary`2[TKey,TValue] expandState, System.String warning) (at Assets/Plugins/FMOD/src/Editor/SettingsEditor.cs:1028)

I believe this is a regression that basically makes the Unity integration unusable. Something to do with de-duplicating platforms in the Platforms map. At runtime there's a series of NPEs related to platforms so actually I can't run the game properly. Has anyone else run into this?

I'm evaluating FMOD as a middleware option for our game, and have run into at least two serious bugs in the Unity integration. See other bug here.

UPDATE:

I haven't found out why this doesn't happen for everyone, but an easy fix for anyone else running into this issue has been applying this diff:

diff --git a/Assets/Plugins/FMOD/src/Runtime/Settings.cs b/Assets/Plugins/FMOD/src/Runtime/Settings.cs
index 2641e926..c2843145 100644
--- a/Assets/Plugins/FMOD/src/Runtime/Settings.cs
+++ b/Assets/Plugins/FMOD/src/Runtime/Settings.cs
@@ -817,6 +817,10 @@ namespace FMODUnity
 
         private void PopulatePlatformsFromAsset()
         {
+            Platforms.Clear();
+            PlatformForBuildTarget.Clear();
+            PlatformForRuntimePlatform.Clear();
+
 #if UNITY_EDITOR
             string assetPath = AssetDatabase.GetAssetPath(this);
             UnityEngine.Object[] assets = AssetDatabase.LoadAllAssetsAtPath(assetPath);
@@ -827,36 +831,8 @@ namespace FMODUnity
 
             foreach (Platform newPlatform in assetPlatforms)
             {
-                Platform existingPlatform = FindPlatform(newPlatform.Identifier);
-
-                if (existingPlatform != null)
-                {
-                    // Duplicate platform; clean one of them up
-                    Platform platformToDestroy;
-
-                    if (newPlatform.Active && !existingPlatform.Active)
-                    {
-                        Platforms.Remove(existingPlatform.Identifier);
-
-                        platformToDestroy = existingPlatform;
-                        existingPlatform = null;
-                    }
-                    else
-                    {
-                        platformToDestroy = newPlatform;
-                    }
-
-                    Debug.LogWarningFormat("FMOD: Cleaning up duplicate platform: ID  = {0}, name = '{1}', type = {2}",
-                        platformToDestroy.Identifier, platformToDestroy.DisplayName, platformToDestroy.GetType().Name);
-
-                    DestroyImmediate(platformToDestroy, true);
-                }
-
-                if (existingPlatform == null)
-                {
-                    newPlatform.EnsurePropertiesAreValid();
-                    Platforms.Add(newPlatform.Identifier, newPlatform);
-                }
+                newPlatform.EnsurePropertiesAreValid();
+                Platforms.Add(newPlatform.Identifier, newPlatform);
             }
 
 #if UNITY_EDITOR

Solution

  • So this was a bug in the integration they fixed in 2.01.10.