punchey
New Member
Posts: 7
Posts: 7
|
Post by punchey on Jan 27, 2016 1:05:34 GMT
I have a single MasterAudio prefab that has all of the SFX I need for every scene in my game, but each scene needs a different set of playlists as well. So I was thinking the easiest thing would be to just add the handful of audio tracks as Playlists at runtime via script (using CreatePlaylist()). However, I'm a little skiddish about this as I don't see any documentation on the Playlist class itself or how to set it up, even though it is a required parameter to CreatePlaylist().
Could I see a simple example of best practices for using the Playlist class in this way?
Also, is there a better approach I should be using for my situation?
|
|
|
Post by DarkTonic Dev on Jan 27, 2016 2:25:07 GMT
|
|
punchey
New Member
Posts: 7
Posts: 7
|
Post by punchey on Jan 28, 2016 23:26:41 GMT
Thanks, this looks like exactly what I was looking for!
|
|
|
Post by DarkTonic Dev on Jan 29, 2016 0:05:37 GMT
No problem.
|
|
punchey
New Member
Posts: 7
Posts: 7
|
Post by punchey on Jan 29, 2016 21:08:51 GMT
Quick follow-up: do the playlists played under the DynamicSoundgroupCreator use the PlaylistController specified in the main MasterAudio GameObject? I'm trying to ensure that my dynamic playlists are using the proper mixer, which is assigned in the main MasterAudio object, but I don't see an equivalent place to assign this in the DynamicSoundGroupCreator. So just wanting to make sure it's going to grab that setting from the main MasterAudio object. Thanks!
|
|
|
Post by DarkTonic Dev on Jan 29, 2016 23:27:39 GMT
They won't get assigned to any controller, since you can have many.
You would need to use a ChangePlaylist command to start playing one of your DGSC Playlists.
You can do this by firing a Custom Event after the DGSC creates its items, then use EventSounds to listen for that Custom Event and change the Playlist. No coding needed.
|
|
punchey
New Member
Posts: 7
Posts: 7
|
Post by punchey on Feb 2, 2016 0:27:33 GMT
I'd prefer to do it in-code. So just to clarify, how would I go about playing a dynamically created playlist so that it uses the mixer assigned to my PlaylistController, realizing that I have playlists both in my DSGC object, and also my main MasterAudio object, and want to be able to easily switch between them at will?
|
|
|
Post by DarkTonic Dev on Feb 2, 2016 0:51:31 GMT
You can do it from code, but you have to make sure that Playlist has already been transferred into the Master Audio game object or it won't do anything (Playlists only play from there, not from the DGSC, which is just a temporary holder). Normally that happens as soon as the DGSC gets enabled. So if you try and do it from an Awake or Start event in some script, that may or may not work depending on Script Execution Order. That's one reason the Custom Event thing exists, so you don't have to mess with that and can be sure it is already created. Anyway, regardless of whether you're using code or not, you should have already hooked up the Mixer Group to the Playlist Controller, which will be used in all cases. For code, as long as it's already in the Master Audio game object (see above comment), you can use this method (ChangePlaylistByName): dl.dropboxusercontent.com/u/40293802/DarkTonic/MasterAudio_API/class_dark_tonic_1_1_master_audio_1_1_master_audio.html#afa54a1cf484d0a0e66b61ef24ad100e4
|
|