luniac
New Member
Posts: 11
Posts: 11
|
Post by luniac on Feb 9, 2016 19:28:16 GMT
Ima try to explain as best i can:
I got persistent master audio object starting at first scene. I got lots of sound groups in it, for simplicity sake each group represents a sound for a different character skin. All audio clips have "preload" unchecked.
In my menu scene player selects a character skin and accordingly in the game scene my script knows which character's sound group to play.
So my question is: Does the sound group clip load into memory the first time it's played in the game scene? Does it ever unload? If it doesn't unload, I'm thinking that if i keep going back to menu scene and selecting all the characters 1 by one and playing their respective sound in the game scene, then eventually all sounds will be loaded into memory.
On the other hand, what if the sound unload when it stops playing, then won't the game keep having to load the sound back into memory over and over when it needs to play?
I know dynamic sound group creator can be used for skins, but i wanna make sure i can't keep it simple for now and just have all the sounds in my persistent master audio object.
Is it possible to make sure all sounds are unloaded upon returning from game scene to menu scene? or even better solution for me: when selecting a character in menu scene i can also at that point load the skins sound group into memory, and if i select a different character i can just unload all sounds and load the new character sounds.(i get that dynamic sound group creator could do this, but i wanna see if i can avoid creating a DSG prefab for every single skin for now, and just do it through script)
|
|
|
Post by DarkTonic Dev on Feb 9, 2016 20:35:56 GMT
Most of the questions here don't need answering because of the following:
1) Yes, the clip gets loaded into memory the first time it's played. 2) The clip get unloaded from memory as soon as it stops playing.
Those are true whether you're using "Preload Audio Data" off or Resource files. The downside is that everything you set up this way will have added latency as they are loaded into memory.
The suggestion that it shouldn't always unload when stopping playing is just asking for bad memory profiling, so I won't consider doing that.
Let me know if you have any other questions.
|
|
luniac
New Member
Posts: 11
Posts: 11
|
Post by luniac on Feb 9, 2016 21:17:00 GMT
Thank for the quick response. lets say i have a sound group containing 20 variations, each variation being a unique audio file. So correct me if im wrong, when i play the sound group it loads and then unloads only the variation picked to play and not all 20 variations belonging to that sound group? Also if i understood it right, do you think it would contribute a noticeable latency on mobiles to constantly play a sound group containing a 0.5 second length non preloaded variation every 0.5 seconds? maybe microstuttering? I also have music playing nonstop in the playlist with streaming compression settings. The way i see it, for sounds such as character dying, i can leave preload unchecked since it will only play when the game is over so i don't care if theres latency because it won't affect the gameplay. However for a sound such as the character attacking, i should keep preload check because otherwise it will load and unload that sound file many many times in the scene. My attack sounds are very very small files with <1 second length, it won't increase my ram usage much even if i preload ALL the skin attack sounds, and i can avoid using dynamic sound groups!
|
|
|
Post by DarkTonic Dev on Feb 10, 2016 0:15:35 GMT
Yes, only the particular Variation that will play is loaded when it needs to play. I don't think it will cause any micro-stuttering. If it's still playing when requested again, then it won't need to load a 2nd time. It will use the already loaded sound. It only gets unloaded when the last Variation of that clip stops. I'm not saying that loading Resources will make the game stutter (affect frame rate), I'm saying that the sounds will not play immediately. But possibly if you are loading a lot of Resource files very often, it can affect performance. Nothing we can do to fix that. It's the way Unity does things.
I don't think Resource files + streaming works correctly, if you're saying you are using that. Resource files have to completely load into memory before playing, so they can't stream. So either use streaming or Resource files for music, not both. Please read the "best practices" section on the docs website for more information.
Correct, I usually keep the often played sounds "always loaded".
|
|
luniac
New Member
Posts: 11
Posts: 11
|
Post by luniac on Feb 10, 2016 0:19:28 GMT
Thanks man all is good now.
|
|
|
Post by DarkTonic Dev on Feb 10, 2016 0:54:14 GMT
You're welcome.
|
|