arafay
New Member
Posts: 24
Posts: 24
|
Post by arafay on Mar 22, 2016 7:47:10 GMT
Hi there, I bought Master Audio during sale, thinking that it will help me in gaming once i start. Today the day has come when i finally need something to intigrate basic music and event sounds and realized that Master Audio is quite complex and even videos are not helping me for my small cases. My current requirements are - i have one music file which i want to keep playing for the whole game for all scenes. How can i do that? + How can i do that using code so i first check if music is turned off/on and then play. - Play simple sounds for clicking buttons etc, and these files too using C# so i can play only if user has allowed sounds. I know Master Audio is much bigger than that, but for now thats what i need, hope to see a detailed reply. Thanks
|
|
|
Post by DarkTonic Dev on Mar 22, 2016 19:42:14 GMT
To make it easier on yourself I would do the following instead of what you suggest for the music part: - Create a bootstrapper Scene as mentioned here: dl.dropboxusercontent.com/u/40293802/DarkTonic/MA_OnlineDocs/BestPractices.htm. Start the music playing in the Bootstrapper Scene. Set "Persist across Scenes" to on in the Master Audio game object you place in that Scene. Now the music will always play, although it may be silent depending on what the user has selected, and you won't need to check if music or SFX are turned on or not. You can use the following code to turn off / on music and / or SFX. PersistentAudioSettings.MixerMuted = true; // mutes all SFX PersistentAudioSettings.MusicMuted = true; // mutes all music
As far as playing SFX for clicking buttons, again I wouldn't bother checking if SFX are turned on or not, just set MixerMuted as shown above and if the UI sounds are told to play, they will do so silently. So use EventSounds script to "Play Sound" for the appropriate Sound Group for the UI event as shown in this video: www.youtube.com/watch?v=45gwLM6D6o0Note that you can also use EventSounds to actually set MusicMuted and MixerMuted instead of writing those lines of code above. Attach the script to a Button and use Action Type "Persistent Settings Control", action Mixer Mute Toggle and Music Mute Toggle. If you still want to trigger SFX from code, use one of the methods of MasterAudio.PlaySoundX (there are many).
|
|
arafay
New Member
Posts: 24
Posts: 24
|
Post by arafay on Mar 28, 2016 17:54:47 GMT
Hi there, Here is the issue with MasterAudio.PlaySoundX
`DarkTonic.MasterAudio.MasterAudio' does not contain a definition for `PlaySoundX'
|
|
|
Post by DarkTonic Dev on Mar 28, 2016 19:51:54 GMT
That's not the actual name of the method, I was being generic with the "X". There are many methods that start with "PlaySound". You will need to decide which you want to use. Consult the API website and/or intelli-sense.
Such as: PlaySound3DFollowTransform OR PlaySoundAndForget.
|
|
arafay
New Member
Posts: 24
Posts: 24
|
Post by arafay on Mar 28, 2016 20:29:00 GMT
Sorry for my ignorance, Thanks for quick reply. There is a problem though, i cant pass an AudioClip to it
|
|
|
Post by DarkTonic Dev on Mar 28, 2016 20:42:07 GMT
All audio clips are set up beforehand in SoundGroups.
You just pass the name of the SoundGroup you want to play to PlaySound methods.
Please read the 3 how to's at the top of the Master Audio documentation website. It explains this and it's short.
|
|
arafay
New Member
Posts: 24
Posts: 24
|
Post by arafay on Mar 28, 2016 21:49:51 GMT
I created an empty scene with Camera only and when i press Create [Master Audio Prefab] doesnt happen. However when i press Playlist Controller Prefab Create then it create a playlist object. But not the first one.
|
|
|
Post by DarkTonic Dev on Mar 28, 2016 21:53:50 GMT
That's fixed in the version I just submitted to the Asset Store. If you don't want to wait, email us with your invoice PDF and we will send it to you.
|
|
arafay
New Member
Posts: 24
Posts: 24
|
Post by arafay on Mar 28, 2016 22:44:22 GMT
Just sent email on support. Please check.
|
|
|
Post by DarkTonic Dev on Mar 28, 2016 23:00:56 GMT
Replied with download link.
|
|