Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

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. Lurking-Ninja

    Lurking-Ninja

    Joined:
    Jan 20, 2015
    Posts:
    9,991
    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.      }