Thursday, April 17, 2014

Dev Blog 69 - Heh, Demo Day!

Going through final preparation for Demo Day, playtesting the demo and making sure everything is working properly.

One thing I noticed was that while the Main Menu has a (temporary) title track, the Level Selection screen and Credits screen don't have any background music playing.

I was wondering how feasible it would be to have the main title track continue playing uninterrupted across all 3 menu screens. I'm thinking if I used DontDestroyOnLoad on the MainCamera (which has both the listener and audio source attached) it might do the trick. The problem is the other scenes would then have 2 cameras and 2 listeners, which is no bueno in Unity. Maybe it's as simple as deleting the camera objects in the other 2 scenes? I'm gunna give it a go real quick.

Update 1 @ 3:20PM: So it wasn't quite as straightforward as I postulated. What I ended up having to do was use DontDestroyOnLoad as I planned, but I couldn't simply remove the MainCamera objects from the other menu scenes. This is because OnGUI requires a GUILayer object, which is attached to and dependent  on a camera object.

So what I did was remove the MainCamera from all menu scenes besides MainMenu, and add a regular camera object with a GUILayer without the MainCamera tag.

This way, I can destroy the MainCamera object when I load a level or return to the main menu. Otherwise the title track would persist into a level, or play twice when you return to the Main Menu (because the MainCamera object with the song attached is still there when you return to the Main Menu with a duplicate of that same object).

With this implementation, the title track stays uninterrupted across the various menu screens, except when you return to the MainMenu. Then it has to start over - I couldn't see a way to have it persist completely, so I'm happy with this implementation.

Now time to pack everything up for Demo Day and head to Northeastern's campus!

No comments:

Post a Comment