Fabric Manual How To'sEvent Notifications

Event Notifications

A new set of PostEventNotify functions are available that allow to post events and get various notifications back such as:

public enum EventNotificationType
{
	OnFinished,
	OnStolenOldest,
	OnStolenNewest,
	OnStolenFarthest,
	OnAudioComponentStopped,
	OnSequenceNextEntry,
	OnSequenceAdvance,
	OnSequenceEnd,
	OnSequenceLoop,
	OnSwitch,
	OnMarker,
	OnRegionSet,
	OnRegionQueued,
	OnRegionEnd,
	OnAudioComponentPlay,
	OnPlay
} 

Here is a script example on how to post an event and listen for a notification.

public void Notify(Fabric.EventNotificationType type, string eventName, object info, GameObject gameObject)
{
    if (info != null)
    {
        if (type == Fabric.EventNotificationType.OnSequenceAdvance)
        {
            Fabric.Component c = info as Fabric.Component;
            if (c != null)
            {
                Debug.Log("Info: " + c.name);
            }
        }
        else if (type == Fabric.EventNotificationType.OnMarker)
        {
            Fabric.MarkerNotficationData c = info as Fabric.MarkerNotficationData;
            if (c != null)
            {
                Debug.Log("Offset: " + c._offset + " - Label: " + c._label);
            }
        }
    }
}

void Update () 
{
    if (Input.GetKeyDown(KeyCode.Alpha1))
    {
        Fabric.EventManager.Instance.PostEventNotify("Simple", gameObject, Notify);
    }
}