|
Post by EnigmaCEO on Sept 23, 2014 3:50:10 GMT
I am having a few challenges getting MasterAudio to work within my framework. I need to be able to create the prefabs and playlists through script only.
Everything works fine when I use the inspector to add everything but not from scripting.
if(!GameObject.Find("MasterAudio")) {
GameObject obj = new GameObject("MasterAudio");
obj.AddComponent<MasterAudio>();
obj.GetComponent<MasterAudio>().persistBetweenScenes = true;
} This is my first issue. Doing this in the Awake() function results in a GameObject that doesn't have a checkbox for Persistance and when the scene changes the Object is destroyed.
AudioClip sound = Resources.Load ("Sound/" + clip, typeof(AudioClip)) as AudioClip;
MasterAudio.AddSongToPlaylist(clip, sound, loop, vol);
MasterAudio.PlaySound(clip, vol); This results in an error that says "Could not find Playlist". This could be me not understanding how to create a playlist through scripting. I am able to drag and drop clips in the inspector and playing them however.
|
|
|
Post by DarkTonic Dev on Sept 23, 2014 14:51:32 GMT
Why do you need to do all that from scripting? I'm curious.
Anyway, it's not as simple as just adding a Master Audio script to a Game Object. That script needs lots of references to other prefabs and scripts. If you want to script the creation of the Master Audio prefab, do what the MasterAudioManager.cs does. Look at the method CreateMasterAudio(). Or just mark that method as public static and call it directly (better idea). I'll make that and the CreatePlaylistController and CreateDynamicSoundGroupCreator methods all public static for the next version.
Let me know what else you run into after that, if anything. I need to mention that this isn't an officially supported method of using MA, but we will offer any assistance we can.
Note that you can't add a song to a playlist when you don't have any Playlists. The first parameter for that method is the Playlist name. That doesn't look like what you passed in.
|
|
|
Post by EnigmaCEO on Sept 23, 2014 15:26:59 GMT
Creating a framework that builds every scene from XML. It works well for UI, Input, Environment, etc but Audio has been tricky and this tool comes the closest so far.
Thanks for the suggestions. I'll make the changes and report back if everything succeeds.
|
|
|
Post by DarkTonic Dev on Sept 23, 2014 15:45:01 GMT
Cool, interested to hear if we can get things working for you without too much trouble. Some very large studios use our product and we built out tons of features for them, so hopefully it's close to what you need.
|
|
|
Post by EnigmaCEO on Sept 23, 2014 16:15:04 GMT
It worked but I had to copy the code because those scripts are separated out as Editor.
Now it seems I need to figure out how to create a DSGC and add an AudioClip to it through the script.
|
|
|
Post by DarkTonic Dev on Sept 24, 2014 1:58:58 GMT
Creating a DSGC, use (copy) the method inside the MasterAudioManager class also.
|
|
|
Post by EnigmaCEO on Sept 24, 2014 9:18:26 GMT
Everything works now from scripting. The only quirk is that now the audio groups under the MasterAudio object remain after scene changes even when the DSGC is set to remove.
|
|
|
Post by DarkTonic Dev on Sept 24, 2014 13:41:22 GMT
Everything works now from scripting. The only quirk is that now the audio groups under the MasterAudio object remain after scene changes even when the DSGC is set to remove. They should not. If you would like to send me a small project that reproduces that error, I'll take a look at why that happens. Did you get any errors or warnings in the console?
|
|