示例#1
0
    private SequencerOneshot GetFreeSequencer()
    {
        foreach (SequencerBase sequencer in driver.sequencers)
        {
            SequencerOneshot oneShot = sequencer as SequencerOneshot;

            if (oneShot && !oneShot.IsBusy && oneShot != activeSequencer)
            {
                return(oneShot);
            }
        }

        return(null);
    }
示例#2
0
    private void PlayBlock(int blockId, BEAT_TIMING timing, Action callbackAtSoundBeginning = null)
    {
        SequencerOneshot shot = GetFreeSequencer();

        if (!shot)
        {
            Debug.LogError("no free sequencer");
            return;
        }

        activeSequencer = shot;

        actualBlock = scenarioManager.GetSoundBlock(blockId);
        AudioClip clip = resourcesManager.GetResource(actualBlock.clipId).Clip;

        if (!clip)
        {
            Debug.LogError("no clip for " + actualBlock.clipId);
            return;
        }

        shot.sequence[(int)timing] = true;
        shot.SetAudioClip(clip);
        shot.SetLoop(actualBlock.isLooping);
        shot.OnAnyStep += () => { Debug.Log("onanystep"); };
        shot.OnBeat    += () => { Debug.Log("onbeat"); };

        if (callbackAtSoundBeginning != null)
        {
            //shot.SetSoundBeginCallback(action);
        }

        if (actualBlock.nextBlock != null)
        {
            //shot.SetNextSoundCallback(NextSoundblock, BEAT_TIMING.ON_2);
        }
    }