- Home /
Audio skipping
I've got a Main Menu setup along with an audio track that loops. For some reason though, when the player clicks on "New Game", the audio starts skipping repeatedly until the game is loaded. Has anybody experienced any similar issues? How might I ensure that the audio doesn't skip while a level is loading? Any help would be very much appreciated! Thank you!
Answer by thorbrian · Nov 21, 2011 at 10:27 PM
Yeah, sometimes loading levels takes forever, and it can mess up music and that sucks. You can try AsyncLevelLoad to see if it helps by making some of the loading happen while the game is playing (it usually doesn't help much though, because it doesn't preload assets, it just streams in the scene itself), but you should consider fading the music out before loading as your simplest solution.
...If you really want great level loading though, you'll actually have to preload assets yourself - often what makes loading a level suck is not actually getting to the level, it's rendering/playing the first frame, where it needs to get all the textures and sounds and stuff. If you have an editor script that builds a list of all the textures and sounds needed for a scene, you can make a preloader for that level that assigns the textures to an offscreen object in batches and that assigns the sounds to an audio source and accesses the data to force loading before the scene is loaded, and that should fix most of the problem.
$$anonymous$$ore than 6 years passed, and this advice is still valid...
Answer by Content1of_akind · Apr 25, 2019 at 05:20 PM
https://docs.unity3d.com/Manual/class-MonoManager.html Edit > Player Settings > Script Execution.
Under (Default Time) click on the Plus(+) Sign on the bottom right to add the Script(GameManager Script) that should run before any other Script. The script name doesn't matter, just the concept of which Script you want to run before another. that being said if the script works do not follow these steps at all, your code is fine as is. Only use it if your script is interfering with time order of another Script from performing properly. Which is usually the GameManager and AudioManager I've only came across.
This is what helped my music to start playing again because my GameManager Script and AudioManager Script was loading(running) at the same or wrong time which I guess caused it not to recognize the AudioManager.instance I wrote to the GameManager. Hope this helps you as it did me, Cheers!
Your answer
Follow this Question
Related Questions
Load Scene by audio clip 2 Answers
Levels, stages, scenes 0 Answers
Checking if arbitrary level is loaded 0 Answers
Need to link a button to next level 1 Answer
Enter new level positions - check for players that might not be there 1 Answer