|
Post by picklesiidx on Jun 25, 2014 16:27:06 GMT
I could use some help with a workflow that will hopefully support how I'm building my game.
I've set my game up in a way that I can load up any scene and play right away. This saves me significant amounts of time instead of loading some start scene and then selecting which level I'd like to go to (especially on console where load times are still long). Because of this, I don't want to use a bootstrapper scene to set up my Master Audio to be persistent across scenes. I've gotten this to work for sounds, but the playlists throw me errors when trying to play or change playlists. The issue is either:
1. The playlist is created in another scene because the music is supposed to start in another scene. In this scenario, I would like it to simply not play any music, instead of throwing me an error. 2. I am reloading a scene with a dynamic playlist, and I will receive an error when reloading the scene saying that a playlist of the given name already exists. It does exist, because I dynamically created it when I first loaded the scene. I would like it to not create another playlist without throwing an error, since it already exists, and I want the music to continue playing.
Is there a way to handle these within the workflow of Master Audio? If not, I'll just change the errors to warnings and keep going, but I'd rather work with the tool as long as I can maintain my fast testing cycles.
|
|
|
Post by DarkTonic Dev on Jun 25, 2014 23:33:23 GMT
#1, Is your Master Audio prefab persistent? What error are you getting? And in which Scene? In what life cycle event are you telling the Playlist to play? #2, That should not happen because reloading the Scene should cause the temporary items to be destroyed (playlists as well) unless you didn't check the box for "auto-remove items". That should happen before they are recreated when the Scene re-loads.
|
|
|
Post by picklesiidx on Jul 14, 2014 17:08:22 GMT
Thanks for responding quickly, and I apologize for not responding myself. I got caught up in other things with the game.
So, #1 was able to be solved simply by naming the playlist on the master audio prefab in the scene where the error was thrown. The exact setup was that I had a title scene with a playlist. The game menu scene didn't have a playlist, as the music is instantiated in the title scene, and my prefabs are persistent. I got an error when opening just the game menu scene, because a playlist that I expected to be there wasnt. I've now added that playlist name the to Master Audio prefab in the game menu scene, I no longer get an error, and the music doesn't play when I load that scene directly, as expected.
#2, reloading the scene, is still causing an issue. I'm reloading with Application.LoadLevel(Application.loadedLevel); When I do check to auto remove the items, when the scene reloads, I get the error saying that I already have a playlist controller with the specified name (in this case 'stadium'). So here are the configurations that I've tried:
Master Audio: Persist Across scenes == true DynamicSoundGroupCreator: Auto Create and Auto Destroy == true, carrying the playlist for the scene's audio PlaylistController: Created in the scene with no initial playlist Result on reload: Playlist Controller 'PlaylistController' is using Playlist 'stadium' so you cannot delete the Playlist. Please change to another Playlist before deleting.
Master Audio: Persist Across scenes == false DynamicSoundGroupCreator: Auto Create and Auto Destroy == true, carrying the playlist for the scene's audio PlaylistController: Created in the scene with no initial playlist Result on reload: Playlist Controller 'PlaylistController' is using Playlist 'stadium' so you cannot delete the Playlist. Please change to another Playlist before deleting. There is no Master Audio prefab in this Scene. Subsequent method calls will fail.
Master Audio: Persist Across scenes == true DynamicSoundGroupCreator: Auto Create == true, Auto Destroy == false, carrying the playlist for the scene's audio PlaylistController: Created in the scene with no initial playlist Result on reload: Cannot add a new Sound Group named 'bird_death_01' because there is already a Sound Group of that name. (I get a result like this for each sound effect I have in the scene) You already have a Playlist Controller with the name 'stadium'. You must name them all uniquely. Ducking and other functions will not function properly until you fix this.
Master Audio: Persist Across scenes == true DynamicSoundGroupCreator: Auto Create and Auto Destroy == true, carrying the playlist for the scene's audio PlaylistController: No playlist controller premade in the scene Result on PLAY: You have no Playlist Controllers in the Scene. You cannot 'ChangePlaylistByName'.
Master Audio: Persist Across scenes == true, carrying the playlist for the scene's audio DynamicSoundGroupCreator: Auto Create and Auto Destroy == true, NOT carrying the playlist PlaylistController: No playlist controller premade in the scene Result on PLAY: You have no Playlist Controllers in the Scene. You cannot 'ChangePlaylistByName'.
Master Audio: Persist Across scenes == true, carrying the playlist for the scene's audio DynamicSoundGroupCreator: Auto Create == true and Auto Destroy == false, NOT carrying the playlist PlaylistController: No playlist controller premade in the scene Result on PLAY: You have no Playlist Controllers in the Scene. You cannot 'ChangePlaylistByName'.
I think that's about as many scenarios as I can reasonably figure out. Got one that I haven't thought of that I should try out? By the way, that ChangePlaylistByName() call is being made in the first update loop.
|
|
|
Post by DarkTonic Dev on Jul 15, 2014 4:30:24 GMT
Yeah the first method for #2 is the one you should use. Should I make that delete the *currently used* playlist and stop it playing (necessary to release resources)? Put the error in there seemed like a good idea at the time.
|
|
|
Post by picklesiidx on Jul 15, 2014 14:56:21 GMT
If I were to get picky, I can imagine wanting both scenarios. In this case, since I'm reloading the same scene, it would be great to keep the music playing. So, having an option to not remove playlists that are currently active would be nice. But, if that option wasn't checked, then it would stop the playlist and delete it. Although that might be having my cake and eating it too. If that's too much trouble, having it stop and delete the music should be fine. If the user does want the music to loop, they can either not auto delete resources, or have that playlist created in a previous scene. Actually, does that work? If I have a playlist from a previous scene that isn't deleted, but then auto delete dynamically loaded resources in a future scene, will it delete the original playlist? I would presume not.
|
|
|
Post by DarkTonic Dev on Jul 15, 2014 16:22:18 GMT
Yeah it would not work, it wouldn't know about the old copy since it's gone already from the Scene. So how would you prefer this to be changed?
|
|
|
Post by picklesiidx on Jul 16, 2014 6:29:53 GMT
From my perspective, it would make the most sense to delete the playlist if auto-delete is checked. That way the user was asking for it. Any other setup should be able to be handled manually.
|
|
|
Post by DarkTonic Dev on Jul 16, 2014 7:32:37 GMT
Ok, I'll add that in the next version. Thanks!
The programmer could always make sure and change playlists before a Scene change so there's no audio dropout in that case.
|
|
|
Post by picklesiidx on Aug 21, 2014 18:10:58 GMT
This is related to the same topic, so I'll post here.
A new issue was found when using LoadLevelAsync(). If I call this function while a sound is playing (even after using MasterAudio.StopAll()) on my next scene I'll get a few errors: 1 - There is no Master Audio prefab in this Scene. Subsequent method calls will fail. UnityEngine.Debug:LogError(Object) MasterAudio:get_Instance() (at Assets/DarkTonic/MasterAudio/Scripts/Singleton/MasterAudio.cs:4038) MasterAudio:get_GroupBuses() (at Assets/DarkTonic/MasterAudio/Scripts/Singleton/MasterAudio.cs:3986) MasterAudioGroup:get_BusForGroup() (at Assets/DarkTonic/MasterAudio/Scripts/Settings/MasterAudioGroup.cs:150) MasterAudioGroup:RemoveActiveAudioSourceId(Int32) (at Assets/DarkTonic/MasterAudio/Scripts/Settings/MasterAudioGroup.cs:136) SoundGroupVariation:Stop(Boolean) (at Assets/DarkTonic/MasterAudio/Scripts/Settings/SoundGroupVariation.cs:333) SoundGroupVariation:StopSoundEarly() (at Assets/DarkTonic/MasterAudio/Scripts/Settings/SoundGroupVariation.cs:158) SoundGroupVariation:OnDestroy() (at Assets/DarkTonic/MasterAudio/Scripts/Settings/SoundGroupVariation.cs:146)
2- NullReferenceException: Object reference not set to an instance of an object MasterAudio.get_GroupBuses () (at Assets/DarkTonic/MasterAudio/Scripts/Singleton/MasterAudio.cs:3986) MasterAudioGroup.get_BusForGroup () (at Assets/DarkTonic/MasterAudio/Scripts/Settings/MasterAudioGroup.cs:150) MasterAudioGroup.RemoveActiveAudioSourceId (Int32 _varInstanceId) (at Assets/DarkTonic/MasterAudio/Scripts/Settings/MasterAudioGroup.cs:136) SoundGroupVariation.Stop (Boolean stopEndDetection) (at Assets/DarkTonic/MasterAudio/Scripts/Settings/SoundGroupVariation.cs:333) SoundGroupVariation.StopSoundEarly () (at Assets/DarkTonic/MasterAudio/Scripts/Settings/SoundGroupVariation.cs:158) SoundGroupVariation.OnDestroy () (at Assets/DarkTonic/MasterAudio/Scripts/Settings/SoundGroupVariation.cs:146)
That will happen a few times (I think it's equal to the number of sounds I'm playing? Might be a single sound with a variation).
Then I'll get:
3 - MissingReferenceException: The object of type 'Transform' has been destroyed but you are still trying to access it. Your script should either check if it is null or you should not destroy the object. MasterAudio.RemoveSoundGroup (UnityEngine.Transform groupTrans) (at Assets/DarkTonic/MasterAudio/Scripts/Singleton/MasterAudio.cs:2053) DynamicSoundGroupCreator.RemoveItems () (at Assets/DarkTonic/MasterAudio/Scripts/Utility/DynamicSoundGroupCreator.cs:99) DynamicSoundGroupCreator.OnDisable () (at Assets/DarkTonic/MasterAudio/Scripts/Utility/DynamicSoundGroupCreator.cs:71)
That'll happen 13 times for me (I presume related to the number of sounds I had playing), and each one causes the level to perform it's Start() calls again.
Any thoughts on this? Once again, this is a setup where each scene has it's own dynamic sound group creator and each one is marked to auto-remove items.
|
|
|
Post by DarkTonic Dev on Aug 21, 2014 22:38:22 GMT
Not sure, I've never used LoadLevelAsync before. Can you try to see if destroying the Dynamic SGC before calling LoadLevelAsync gets rid of the errors and let me know?
|
|
|
Post by picklesiidx on Aug 21, 2014 23:34:05 GMT
Well, it works a little better. Down to 8 errors. I tried both Destroy() and DestroyImmediate() after using GameObject.Find to get the Dynamic SGC.
|
|
|
Post by picklesiidx on Aug 21, 2014 23:45:16 GMT
I followed the null references, adding in null checks before them. Now, when I load up a scene I'll get this 8 times, which causes the music to play, stop, and then reload the scene again. After 8 times, it goes through:
The song 'music_title_screen_part_II' is already playing. Ignoring song change request. UnityEngine.Debug:LogWarning(Object) PlaylistController:PlaySong(MusicSetting) (at Assets/DarkTonic/MasterAudio/Scripts/Utility/PlaylistController.cs:621) PlaylistController:PlayNextSong() (at Assets/DarkTonic/MasterAudio/Scripts/Utility/PlaylistController.cs:413) PlaylistController:PlayNextOrRandom() (at Assets/DarkTonic/MasterAudio/Scripts/Utility/PlaylistController.cs:568) PlaylistController:Start() (at Assets/DarkTonic/MasterAudio/Scripts/Utility/PlaylistController.cs:132)
|
|
|
Post by picklesiidx on Aug 21, 2014 23:50:58 GMT
Okay, I'm thinking the 8 loads is something else in my code. So don't worry about that aspect. But, I'd like to know if just adding in the null checks is fine. Theses are the locations I added them in:
MasterAudio.cs line 3978 MasterAudio.cs line 2975
|
|
|
Post by DarkTonic Dev on Aug 22, 2014 0:14:44 GMT
Are you on the very latest version of MA? I just submitted a large update and I want to make sure I add null checks in the right place. So please update to the latest and let me know the line numbers please. I'll see if that's ok or not.
|
|
|
Post by picklesiidx on Aug 22, 2014 0:35:35 GMT
I'm up to date as far as the Asset Store is concerned. My Release Notes say 3.5.5
|
|