golio
New Member
Posts: 2
Posts: 2
|
Post by golio on Dec 26, 2014 16:54:54 GMT
Hi,
I have a Settings Screen where you can control the audio volume of certain audio groups like e.g.: Background Music, Character sounds etc... When such a (NGUI) slider gets moved I play a related sound or music clip for 3 Seconds. While the slider changes the sound should keep playing with the given volume setting. I store the volume setting in the PlayerPrefs.
I have done all this already with custom code but I try to change my game to use Master Audio right now.
|
|
DarkTonic Dev
Administrator
Posts: 4,386
Posts: 4,386
Member is Online
|
Post by DarkTonic Dev on Dec 26, 2014 20:59:17 GMT
We already have an implementation of storing things in PlayerPrefs and retrieving it automatically. It's called PersistentSettings. Look at section 14 in the readme (short). Basically you should be using commands like this from the NGUI event.
PersistentAudioSettings.MusicVolume = 0.7f; PersistentAudioSettings.SetBusVolume("Dialogue", .8f);
As far as playing something for X seconds and stopping it, you will need to code that yourself. There's no way to do it with our API. On our menu screen we have music playing constantly, so you can hear the volume change. And we play a very short sound effect when the other slider changes (maybe 0.5 seconds). I suggest you do the same if feasible.
|
|
golio
New Member
Posts: 2
Posts: 2
|
Post by golio on Dec 26, 2014 23:16:43 GMT
Thanks. I changed my code and use PersistenAudioSettings now.
The Playing of Sounds for a certain time. I solved like this:
I created a Audio Group named "Settings" and a Bus named "Settings". To the Audio Group I added four sounds as variations (I have four volume sliders). When one of the volume slider is changed I play the associated variation.
I set the "Settings"-Bus to accept only one Voice and stop the old one. So when someone uses different volume sliders in a short time only the sound of the last used slider is played.
I use an endless Coroutine to check when the last change to one of the slider happened. If it exceeds 4 Seconds I stop all sounds of the "Settings"-Group.
So far it works.
Perhaps it would be better make 4 small sound samples with 4 seconds duration. That way It would be possible to skip the Coroutine.
|
|
DarkTonic Dev
Administrator
Posts: 4,386
Posts: 4,386
Member is Online
|
Post by DarkTonic Dev on Dec 27, 2014 0:45:18 GMT
Yeah I'd get rid of that CoRoutine and make some shorter sounds like you said. Sounds good!
|
|