Post by ululu on Jan 5, 2022 7:21:36 GMT
Heya! Thanks again for the great plugin! Everything is working pretty well out of the box, but I need more flexibility than the vanilla system.
To give out a bit of context, when generating a level I do not know in advance what it's content will be, and therefore have to design/build a system around this limitation.
The easy way to do it is for me to store the audio infos my game ingredients will require in their own Scriptable Data, and during the loading, fetch all this info, trim it, and instantiate as needed.
To make things simpler, in my bootstraper I pre-created the sound groups with a dummy sound, and feed them during that loading ( It works wonders for the most part with 150+ audio sources per scene).
The latest hickup I'm facing is that I am not able to make some of these variations loop at runtime.
Via code (see below), either via accessing the audio sources directly or via the group variation script, I manage to set the Loop to true once, but once it's done playing it stops and both the bools (Source+Group) turn to false.
At first I only accessed the AudioSource directly but nothing happened, so I made the _audioLoops bool in the SoundGroupVariation script accessible, and modify it at the same time as the AudioSource. Now the inspector values are good, but once it finishes playing the sound stops and both the bools turn to false.
Could you help me find if it's normal behaviour ? I'd rather not hook up to the Event System to turns them back on manually if possible.
Thank you so much!
Code Example:
Edit: Fixed a tab space typo in the code snippet.
To give out a bit of context, when generating a level I do not know in advance what it's content will be, and therefore have to design/build a system around this limitation.
The easy way to do it is for me to store the audio infos my game ingredients will require in their own Scriptable Data, and during the loading, fetch all this info, trim it, and instantiate as needed.
To make things simpler, in my bootstraper I pre-created the sound groups with a dummy sound, and feed them during that loading ( It works wonders for the most part with 150+ audio sources per scene).
The latest hickup I'm facing is that I am not able to make some of these variations loop at runtime.
Via code (see below), either via accessing the audio sources directly or via the group variation script, I manage to set the Loop to true once, but once it's done playing it stops and both the bools (Source+Group) turn to false.
At first I only accessed the AudioSource directly but nothing happened, so I made the _audioLoops bool in the SoundGroupVariation script accessible, and modify it at the same time as the AudioSource. Now the inspector values are good, but once it finishes playing the sound stops and both the bools turn to false.
Could you help me find if it's normal behaviour ? I'd rather not hook up to the Event System to turns them back on manually if possible.
Thank you so much!
Code Example:
foreach (var clip in ambiancesToLoad) /// Generating ambiance variations
{
MasterAudio.CreateGroupVariationFromClip("Ambiance", clip, clip.name);
timerYield--;
if (timerYield > 0) continue;
yield return null;
timerYield = baseTimerYield;
}
foreach (var source in MasterAudio.GetGroupInfo("Ambiance").Group.groupVariations) /// Making ambiance variations loop
{
source._audioLoops = true; //This is not a public setting out of the box.
source.VarAudio.loop = true; //This is the audio source attached to the variation.
}
Edit: Fixed a tab space typo in the code snippet.