Search Unity

Question Prevent audio from pausing when game is unfocused / minimized / in the background.

Discussion in 'Audio & Video' started by coska, Dec 8, 2022.

  1. coska

    coska

    Joined:
    Dec 8, 2022
    Posts:
    6
    Hello!

    I have a question regarding Unity/Wwise: Is there a way to prevent audio from pausing while the game is unfocused / minimized / in the background? I'm using the word "pausing" here, because when the game returns to focus / foreground, the audio resumes exactly from where it was paused.

    The destination platform is Windows and this issue is when playing the Build only, not when playing in Unity Editor.

    Thank you.
     
  2. Have you tried https://docs.unity3d.com/ScriptReference/Application-runInBackground.html ?
     
    coska likes this.
  3. coska

    coska

    Joined:
    Dec 8, 2022
    Posts:
    6
    Hey Lurking-Ninja, I didn't get an email notification on your reply, so I haven't seen it until now, nor have I tried your suggestion. But thanks for replying!

    I managed to solve this issue by adding one entry (line 4) in the AkSoundEngineController.cs script (the Debug line)

    Code (CSharp):
    1.  
    2. {
    3. #if !UNITY_ANDROID
    4.          if (UnityEngine.Debug.isDebugBuild)
    5.          ActivateAudio(focus, AkWwiseInitializationSettings.ActivePlatformSettings.RenderDuringFocusLoss);
    6. #endif
    7.      }