Audiokinetic's Community Q&A is the forum where users can ask and answer questions within the Wwise and Strata communities. If you would like to get an answer from Audiokinetic's Technical support team, make sure you use the Support Tickets page.

+8 votes

Apologies if this is covered somewhere. If it has been, my google-fu has failed me. I'm using WWise 2021.1.4.7707 and Unity 2021.1.19f1

When I enable Enter Play Mode Settings and then disable either Reload Domain or Reload Scene or both WWise stops working and gives various errors. Mostly of the following sort:

Wwise: Unknown listener game object ID. Make sure the game object is registered before using it and do not use it once it was unregistered.

Wwise: Unknown game object ID. Make sure the game object is registered before using it and do not use it once it was unregistered.

Before going about trying to fix-up WWise C# files to work with Enter Play Mode Settings I thought I'd ask if anyone has had any luck doing so, knows of planned support for them, or know of a reason it won't ever work.

Thanks!

in General Discussion by Najati I. (180 points)
This makes working with WWise in Unity MUCH slower, because this is one of the things that Unity provides to have quicker play-test times.

Its not that hard to set variables OnAwake properly, which is what it requires, as it wont reset from whatever the Editor values where because of no Domain Reloading (clearing everything).

Please prioritize this feature, as iteration times on game developer is one of the top factors in making progress (play testing after changes), and Unity can be VERY slow without Domain Reloading disabled.  I have to choose between having any sound and being able to play quickly.

2 Answers

0 votes
thank you! My project has voice at least.
by jun s. (150 points)
+2 votes

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

by Andrei M. (720 points)
edited by Andrei M.
...