Hey Gabriel,
Do you need all of this to loop from posting the Event once?
If not, then maybe you could reuse the same Music Switch Container in Wwise and post it separately on each "block" and use the EndOfEvent callback to know when to call the next block?
That said, to keep track of this mechanism from the game side as well, I would probably control it with a List where you add each selected block to.
Here's a quick suggestion of such a script. It first adds all the blocks being picked using OnAddingBlock() and then when you start it with ActivateBlock() it runs until there are no more blocks in the list.
* If you need to learn more about Callbacks, you should take a look in the Wwise-301 course.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BlockController : MonoBehaviour
{
public List<GameObject> blocks = new List<GameObject>(); // The List
public int CurrentBlocNumber = 0;
public AK.Wwise.Event MusicSwitchContainer; // Would work fine with just an Actor Mixer Switch Container instead.
public AK.Wwise.CallbackFlags callbackForcingNext; // Just pick EndOfEvent here.
public GameObject Block01;
public GameObject Block02;
private void Start() // This function is just for test purposes.
{
OnAddingBlock(Block01, "Block01");
OnAddingBlock(Block02, "Block02");
ActivateBlock();
}
void OnAddingBlock(GameObject theBlockToAdd, string nameOfBlockSwitch) {
AkSoundEngine.SetSwitch("BlockGroup", nameOfBlockSwitch, theBlockToAdd); // only needs to be set once you add block
blocks.Add(theBlockToAdd); // add block to end of list.
}
void ActivateBlock() {
// Post Event + callback.
MusicSwitchContainer.Post(blocks[CurrentBlocNumber], callbackForcingNext, CallbackFunction);
CurrentBlocNumber++;
}
void CallbackFunction(object in_cookie, AkCallbackType in_type, object in_info)
{
// if there's blocks left in the list, then activate next one.
if (CurrentBlocNumber < blocks.Count) {
ActivateBlock();
}
}
}
Let us know if this is helpful.