Hi, I had this exact issue and I found a fix for it.
Your question seems to have great visibility, it's one of the first results on Google when searching for "wwise unity domain reload" or "wwise unity enter play mode".
So, I'll post here all the fixes I've found related to Wwise and disabled Domain Reload. :)
I hope that Audiokinetic can study and apply these fixes to Wwise, so we don't have to always reapply the fixes when upgrading Wwise. xD
These fixes were tested with:
Wwise 2021.1.10.7883
Wwise Integration 2021.1.10.7883.2429
Unity 2022.1.20f1 (the fixes should work regardless of the Unity version)
Windows 10
First, the main fix for your issue.
In the script AkSoundEngine.extensions.cs (from Wwise\API\Runtime), you should make the following changes:
using UnityEngine; // Add this
// Add this method to reload the RegisteredGameObjects list when Domain Reload is disabled.
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)]
private static void Init()
{
RegisteredGameObjects = new System.Collections.Generic.HashSet<ulong>();
}
// Remove "readonly" flag, for the above method to work.
private static System.Collections.Generic.HashSet<ulong> RegisteredGameObjects =
new System.Collections.Generic.HashSet<ulong>();
I also added some code to AkGameObj.cs (from Wwise\MonoBehaviour\Runtime), to avoid Unity throwing an unhandled exception every time we enter Play Mode while we're debugging the editor and Domain Reload is disabled:
private void OnDestroy()
{
#if UNITY_EDITOR
if (!AkSoundEngine.EditorIsSoundEngineLoaded || AkUtilities.IsMigrating)
return;
if (!UnityEditor.EditorApplication.isPlaying)
UnityEditor.EditorApplication.update -= CheckStaticStatus;
// Add the 2 lines below the comments: Fix for disabled Domain Reload
// Don't run OnDestroy if we're about to enter Play Mode
if (!UnityEditor.EditorApplication.isPlaying && UnityEditor.EditorApplication.isPlayingOrWillChangePlaymode)
return;
#endif
// We can't do the code in OnDestroy if the gameObj is unregistered, so do it now.
var eventHandlers = gameObject.GetComponents<AkTriggerHandler>();
foreach (var handler in eventHandlers)
{
if (handler.triggerList.Contains(AkTriggerHandler.DESTROY_TRIGGER_ID))
handler.DoDestroy();
}
#if UNITY_EDITOR
if (!UnityEditor.EditorApplication.isPlaying)
return;
#endif
if (AkSoundEngine.IsInitialized())
AkSoundEngine.UnregisterGameObj(gameObject);
}
Here are some other fixes that I use for disabled Domain Reload, to avoid the game/editor constantly slowing down each time you enter Play Mode:
https://www.audiokinetic.com/qa/8767/unity-wwise-2021-making-game-stutter-reload-domain-disabled