Audio Keeps Playing while rest of Application is Paused

Our application has Audio Clips loaded from Resources. We are playing them in synch with corresponding Animations. Whenever the user takes mouse focus away from the Unity Window (either in Standalone Run mode, or in Editor) -- the Animation Stops updating (pauses) but the AudioClip continues playing at full speed. So when you restore mouse focus to the Unity application, they are now out-of-synch.

Is there a SIMPLE way to make my Audio Sources Pause along with the rest of the application? I'd like to find a way to make this be my default setting for Loaded Audio Clips and Audio Sources, without special "OnPause()", etc, handling code.

NOTE: We have one Audio Clip that is dropped into the scene (i.e. NOT a Loaded Resource), and it behaves correctly (i.e. it pauses along with rest of application). So the question here is "how do we make Loaded Audio Clips behave the same as AudioClips dropped into the scene directly?" (i.e. Pause when the rest of the application pauses).

Thanks for your help!

I don't see any way to make them behave like one that was dropped in the editor.

I would make that "OnPause" function using MonoBehaviour.OnApplicationPause

Notice it has a single IsPaused bool parameter.


Seems that you are running your application on windowed mode.

so what I would do is to check the screen coordinates of the mouse and check that they are inside your window. and if the user clicks outside of the window then pause your audio sources.

hope it helps.