Wwise/Unity & The Linux Cloud Build Saga
If you use Git CI/CD with a Linux Virtual Machine to cloud build your Unity projects (with Wwise integration) and your builds fail, here’s a troubleshooting guide:
Install Linux implementation to your project. Seems obvious, but worth noting that even if you don’t intend to deploy your final product on Linux, if it’s building from that platform, you will need the integration. Otherwise you will get missing namespace errors from the common API settings.
Generate Soundbanks (probably not needed, but just ensure the integration is working fine). Check your GeneratedSoundbanks folder for all platforms.
Now for the fun stuff. The Wwise API code uses a lot of partial classes that exist across multiple platforms. It also uses Windows as a default setting where conditional compilation doesn’t specify a different platform. So, we need to ensure the compilation conditions are accurate.
All the .cs files in Assets/Wwise/API/Runtime/Generated/Linux should have a _Linux suffix. They need their conditions changed from
#if UNITY_STANDALONE_LINUX && ! UNITY_EDITOR
to
#if (UNITY_STANDALONE_LINUX && !UNITY_EDITOR) || UNITY_EDITOR_LINUXMake the same changes to the .cs files in Assets/Wwise/API/Runtime/Handwritten/Linux:
#if UNITY_STANDALONE_LINUX && ! UNITY_EDITOR
to
#if (UNITY_STANDALONE_LINUX && !UNITY_EDITOR) || UNITY_EDITOR_LINUXIn Assets/Wwise/Wwise/API/Runtime/Handwritten/Common/AkSoundEngine.cs. You’ll find six static methods calls from around line 535 to 625. It looks like:
public static AKRESULT SeekOnEvent(uint in_eventID, UnityEngine.GameObject in_gameObjectID, float in_fPercent, bool in_bSeekToNearestMarker, uint in_PlayingID)
{
var in_gameObjectID_id = AkSoundEngine.GetAkGameObjectID(in_gameObjectID);
AkSoundEngine.PreGameObjectAPICall(in_gameObjectID, in_gameObjectID_id);
#if (UNITY_SWITCH || UNITY_ANDROID || UNITY_STANDALONE_LINUX || UNITY_WEBGL) && !UNITY_EDITOR
return (AKRESULT)AkSoundEnginePINVOKE.CSharp_SeekOnEvent__SWIG_6(in_eventID, in_gameObjectID_id, in_fPercent, in_bSeekToNearestMarker, in_PlayingID);
#else
{ return (AKRESULT)AkSoundEnginePINVOKE.CSharp_SeekOnEvent__SWIG_9(in_eventID, in_gameObjectID_id, in_fPercent, in_bSeekToNearestMarker, in_PlayingID); }
#endif
}The #if (UNITY_SWITCH || UNITY_ANDROID || UNITY_STANDALONE_LINUX || UNITY_WEBGL) && !UNITY_EDITOR here will not work.
The && !UNITY_EDITOR makes for a bad time. So, what you need to do, is duplicate the first #if region and make the duplicate an #elif.
Then remove UNITY_STANDALONE_LINUS from the first #if condition and replace the #elif condition to (UNITY_STANDALONE_LINUX && !UNITY_EDITOR) || UNITY_EDITOR_LINUX. Example:
public static AKRESULT SeekOnEvent(uint in_eventID, UnityEngine.GameObject in_gameObjectID, float in_fPercent, bool in_bSeekToNearestMarker, uint in_PlayingID)
{
var in_gameObjectID_id = AkSoundEngine.GetAkGameObjectID(in_gameObjectID);
AkSoundEngine.PreGameObjectAPICall(in_gameObjectID, in_gameObjectID_id);
#if (UNITY_SWITCH || UNITY_ANDROID || UNITY_WEBGL) && !UNITY_EDITOR
return (AKRESULT)AkSoundEnginePINVOKE.CSharp_SeekOnEvent__SWIG_6(in_eventID, in_gameObjectID_id, in_fPercent, in_bSeekToNearestMarker, in_PlayingID);
#elif (UNITY_STANDALONE_LINUX && !UNITY_EDITOR) || UNITY_EDITOR_LINUX
return (AKRESULT)AkSoundEnginePINVOKE.CSharp_SeekOnEvent__SWIG_6(in_eventID, in_gameObjectID_id, in_fPercent, in_bSeekToNearestMarker, in_PlayingID);
#else
{ return (AKRESULT)AkSoundEnginePINVOKE.CSharp_SeekOnEvent__SWIG_9(in_eventID, in_gameObjectID_id, in_fPercent, in_bSeekToNearestMarker, in_PlayingID); }
#endif
}This change needs to be made across all of the methods with this compilation condition. Again, it should only be six.
It’s worth noting if you update Wwise, you’ll likely have to do this again.
I couldn’t find much useful information regarding this online, so really hope this helps anyone who faces similar to what I did.
Happy audio-ing.