Wwise Integration 2017.2.1.6524.980
After our sound designer changes the Wwise project and generates updated SoundBanks, we sometimes get mismatching references in Wwise Components in Unity. Components like AkState and AkAmbient serialize references to SoundBank data like Events and States as int values that are mapped via a custom Inspector implemented in AkBaseInspector and inheriting classes AkEventInspector and AkStateInspector.
This boils down to a MAJOR issue and a MINOR issue for using Wwise for Soundbanks with Events and States:
- Major issue: Wwise Editor apparently reassigns Event and State IDs. This should never be the case for them to be reliably referenced from Unity side.
- Minor issue: In Unity, custom Inspector code runs UpdateIds method, which can rewrite the eventID and State m_groupID/m_valueID fields. This makes it really confusing when first audio breaks while testing, then suddenly it has been fixed and you've just wasted hours debugging and trying to make changes in both Wwise and Unity. It took me a full evening to even figure out that it's Inspector GUI code that just "fixed" my problem by rewriting the outdated references to something new. And I still don't know how the GUI code worked out which is the correct new ID, if the old ID was out-of-date and unreferenceable in the first place.
AkEvents have a serialized field named "eventID".
AkStates have serialized fields named "m_groupID" and "m_valueID".
When you select an Event or State via Wwise Picker UI tool, the Inspector saves the reference via a numerical ID into eventID for AkEvents (for instance AkAmbient to play music by posting an Event on Start) or m_groupID and m_valueID for AkState (for instance to send a State to alter music sub-state in a multi-piece songs). These saved values MUST be the same for the data in the Wwise-generated soundbank data files and in the aforementioned Unity Components which have their data (the selected events and states to play) saved as part of Scene files or Prefabs inside Unity project.
There seems to be something wrong with the Unity Integration or the Wwise Editor generating the soundbanks in the latest version, since for us Wwise is reassigning the Event/State IDs when the banks are generated and the Wwise project is saved, instead of maintaining the same, reliable ID for the same Event etc. This creates a mismatch between the Wwise soundbanks and the IDs serialized by audio Components in Unity.
Now when our sound designer changes pretty much anything in Wwise, all Scenes that have AkAmbient Components in them to play music produce this error, breaking all music in the project:
Could not post event ID "1239046959". Did you make sure to load the appropriate SoundBank?
AkEvent:HandleEvent(GameObject) (at Assets/Wwise/Deployment/Components/AkEvent.cs:86)
AkAmbient:HandleEvent(GameObject) (at Assets/Wwise/Deployment/Components/AkAmbient.cs:116)
AkUnityEventHandler:Start() (at Assets/Wwise/Deployment/Components/AkUnityEventHandler.cs:55)
Wwise: Event ID not found: 1239046959 (GameObject: Ambient (UnityEngine.GameObject)) (Instance ID: 18446744073709245984)
AkCallbackManager:PostCallbacks() (at Assets/Wwise/Deployment/API/Handwritten/AkCallbackManager.cs:309)
AkSoundEngineController:LateUpdate() (at Assets/Wwise/Deployment/Components/AkSoundEngineController.cs:78)
AkInitializer:LateUpdate() (at Assets/Wwise/Deployment/Components/AkInitializer.cs:113)
Wwise Unity Integration's Component Inspectors seem to be able to fix and update the integer references to IDs, but that is useless for workflow and time reasons: it clearly shouldn't be the case that every time you make a change in the Wwise project everything needs to be setup again in Unity project for every Scene and GameObject/Prefab that plays sound, even if the per-object fix is as simple as selecting the GameObject with AkAmbient/AkState Component on it so it's custom Inspector will automatilly call UpdateIds method and reset these values to what the changed Ids are in the generated Wwise soundbank data. I think these IDs should remain consistent if you only change transitions/volumes and configurations in Wwise project, that don't explicitly remove and rename Events and States.
Here are screen captures of AkAmbient and AkState Components automatically modifying the serialized fields when switching to Normal Inspector from Debug, and the Wwise custom AkBaseInspector.UpdateIds method is run:
- AkState State ID mismatch being "magically" fixed by observing a Component in Scene:
- AkAmbient Event ID mismatch being "magically" fixed by observing a Component in Scene:
Now, we have AkAmbient Components set up in many level Scenes, and will have some references to Ak.Wwise.Event/Ak.Wwise.State in our own scripts too, and we can't simply edit every sound-emitting object after sound design changes and rebalances over and over again.
- What can we do as a short-term solution to our workflow to avoid repetitive ID changes in Unity?
- Does anyone know if there's a possible misconfiguration/gotcha/trick we may have missed when setting up the integration that would cause this kind of confusing ID mismatching? It still seems to me that Wwise should not logically reassign IDs to something that already has an ID, so it would be logical for it to be a mistake on my end.
- Is there something wrong with the latest Wwise Integration update, since we are running quite a fresh version?