- Home /
when I relauch my game the background music is gone
I've made a little game with a short .aif background music track which works perfectly. The audio is attached to the main camera it plays on wake and loops. If I click the home button on my iphone the game is put in the background. When I click the game icon again I'm back in the game but the music doesn't play any longer - what am I doing wrong?
Thanks Jeppe
I want to answer, "owning an iphone", but that's not helpful.
as you say: not very helpful but you may be right :)
Answer by Meltdown · Dec 29, 2010 at 12:20 PM
Add in a script that checks for when your game has received focus again, then explicitly start playing the sound again.
void OnApplicationFocus() {
audio.Play(); // Put your code here to start your background music...
}
Your answer
![](https://koobas.hobune.stream/wayback/20220613093059im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
include audio with animation 1 Answer
Unintended audio gaps 1 Answer
Music will not change when an event triggers it 3 Answers
Animation event triggering step on frame 0 Answers
Playing Music Problem. 2 Answers