Click or drag to resize

Using events

RhythmTool's Events

RhythmTool has a number of events:

RhythmEventProvider

The RhythmEventProvider Component provides a number of useful events and features. It can be given a RhythmTool component that will be used to trigger a number of events.

It can also be given an offset, so events can be triggered ahead of time.

Event Inspector

In addition to each of RhythmTool's events, the following events are available:

For example, to subscribe to the Beat event:

C#
public RhythmEventProvider eventProvider;

void Start()
{
    eventProvider.Beat += OnBeat;
}

private void OnBeat(Beat beat)
{
    Debug.Log("A beat occured at " + beat.index);
}

When using events in C# with Unity, make sure to unsubscribe from events for Components that are destroyed. Otherwise the subscribed method will still be called even if the Component is destroyed.

C#
void OnDestroy()
{
    eventProvider.Beat -= OnBeat;
}