# Get timeline marker callbacks from referenced events

**URL:** <https://qa.fmod.com/t/get-timeline-marker-callbacks-from-referenced-events/16233>\
**Category:** Unity\
**Created:** [September 29, 2020, 1:55am UTC](https://qa.fmod.com/t/get-timeline-marker-callbacks-from-referenced-events/16233 "2020-09-29T01:55:33Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![BadDreamGames](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/baddreamgames/32/1581_2.png) [@BadDreamGames](https://qa.fmod.com/u/BadDreamGames)\
**Post date:** [September 29, 2020, 1:55am UTC](https://qa.fmod.com/t/get-timeline-marker-callbacks-from-referenced-events/16233/1 "2020-09-29T01:55:34Z")

</div>

I’m implementing some rhythm-based mechanics where things happen in the game in response to timeline marker callbacks. The rhythmic pattern of callbacks is repetitive, and I want to contain all those markers in a referenced event for ease of comprehension and editing. However, it seems that Unity is no longer getting those marker callbacks when they are inside a referenced event. Is it possible to get these callbacks in Unity?

 ![fmod-referenced-event-01](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/e/eefc44b38312fe394bccdacd10ac5c27883c88f2.jpeg) ![fmod-referenced-event-02](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/e/ea0aeb7c4d2a815c386e47d3dce79213cf2a2916.jpeg)

---

<div class="post-metadata">

**Author:** ![mathew](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/mathew/32/431_2.png) [@mathew](https://qa.fmod.com/u/mathew)\
**Post date:** [September 30, 2020, 4:24am UTC](https://qa.fmod.com/t/get-timeline-marker-callbacks-from-referenced-events/16233/2 "2020-09-30T04:24:47Z")

</div>

Which version of FMOD are you using?  
We fixed an issue with marker callbacks not propagating from nested events in 2.00.11.

---

<div class="post-metadata">

**Author:** ![BadDreamGames](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/baddreamgames/32/1581_2.png) [@BadDreamGames](https://qa.fmod.com/u/BadDreamGames)\
**Post date:** [September 30, 2020, 7:32pm UTC](https://qa.fmod.com/t/get-timeline-marker-callbacks-from-referenced-events/16233/3 "2020-09-30T19:32:12Z")

</div>

I’m using FMOD version 2.00.11 (and the associated Unity integration) and Unity 2019.3.15

---

<div class="post-metadata">

**Author:** ![mathew](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/mathew/32/431_2.png) [@mathew](https://qa.fmod.com/u/mathew)\
**Post date:** [October 1, 2020, 4:50am UTC](https://qa.fmod.com/t/get-timeline-marker-callbacks-from-referenced-events/16233/4 "2020-10-01T04:50:47Z")

</div>

I couldn’t tell from your image but are those markers two levels deep? I’ve just done a test here and timeline markers fire to callbacks for Events and Nested Events, just not any deeper than that. I’ve issued a task to have that fixed, it’s supposed to work for any level of nesting.

---

<div class="post-metadata">

**Author:** ![BadDreamGames](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/baddreamgames/32/1581_2.png) [@BadDreamGames](https://qa.fmod.com/u/BadDreamGames)\
**Post date:** [October 2, 2020, 6:42pm UTC](https://qa.fmod.com/t/get-timeline-marker-callbacks-from-referenced-events/16233/5 "2020-10-02T18:42:52Z")

</div>

That’s only a single level of nesting - the timeline markers are in the event that the top-level event references. To be crystal clear: the first image is the top-level event, with references to the second event in the first layer (named “Markers”) and the second image is the full contents of said event. That’s what you mean by a single level of nesting, correct?

Thanks for looking into it! I’ll experiment some more and let you know if I figure anything out.

---

<div class="post-metadata">

**Author:** ![mathew](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/mathew/32/431_2.png) [@mathew](https://qa.fmod.com/u/mathew)\
**Post date:** [October 5, 2020, 12:37am UTC](https://qa.fmod.com/t/get-timeline-marker-callbacks-from-referenced-events/16233/6 "2020-10-05T00:37:23Z")

</div>

Yes, that certainly sounds like a single level of nesting and if you are on 2.00.11 that should be working. Is there any chance the libs you are using are from an older version?

---

<div class="post-metadata">

**Author:** ![BadDreamGames](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/baddreamgames/32/1581_2.png) [@BadDreamGames](https://qa.fmod.com/u/BadDreamGames)\
**Post date:** [October 5, 2020, 11:43pm UTC](https://qa.fmod.com/t/get-timeline-marker-callbacks-from-referenced-events/16233/7 "2020-10-05T23:43:25Z")

</div>

I re-downloaded and -imported 2.00.11 unity integration - libs are all current - still no luck

---

<div class="post-metadata">

**Author:** ![tristanjl](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/tristanjl/32/261_2.png) [@tristanjl](https://qa.fmod.com/u/tristanjl)\
**Post date:** [October 5, 2020, 11:46pm UTC](https://qa.fmod.com/t/get-timeline-marker-callbacks-from-referenced-events/16233/8 "2020-10-05T23:46:28Z")

</div>

Hey BadDreamGames

Can you confirm that you are registering the callback on the top level event, not on the nested event?

---

<div class="post-metadata">

**Author:** ![BadDreamGames](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/baddreamgames/32/1581_2.png) [@BadDreamGames](https://qa.fmod.com/u/BadDreamGames)\
**Post date:** [October 6, 2020, 12:32am UTC](https://qa.fmod.com/t/get-timeline-marker-callbacks-from-referenced-events/16233/9 "2020-10-06T00:32:51Z")

</div>

I’m calling `EventInstance::setCallback` on the top level event, is that what you mean?

> `_musicFmodCallback = new EVENT_CALLBACK(FMODEventCallback); _musicEventInstance.setCallback(_musicFmodCallback, EVENT_CALLBACK_TYPE.TIMELINE_BEAT | EVENT_CALLBACK_TYPE.TIMELINE_MARKER);`

> `[AOT.MonoPInvokeCallback(typeof(EVENT_CALLBACK))] static FMOD.RESULT FMODEventCallback(EVENT_CALLBACK_TYPE type, EventInstance instance, IntPtr parameterPtr) { //... }`

…where `_musicEventInstance` is the top-level event (1st image).

---

<div class="post-metadata">

**Author:** ![mathew](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/mathew/32/431_2.png) [@mathew](https://qa.fmod.com/u/mathew)\
**Post date:** [October 6, 2020, 4:29am UTC](https://qa.fmod.com/t/get-timeline-marker-callbacks-from-referenced-events/16233/10 "2020-10-06T04:29:17Z")

</div>

I’ve just done a quick proof of concept test in 2.00.11 and it’s working for me. Perhaps compare what I have here with your version.

```auto
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class CallbackTest : MonoBehaviour
{
    FMOD.Studio.EVENT_CALLBACK _musicFmodCallback;
    FMOD.Studio.EventInstance _musicEventInstance;

    [AOT.MonoPInvokeCallback(typeof(FMOD.Studio.EVENT_CALLBACK))]
    static FMOD.RESULT FMODEventCallback(FMOD.Studio.EVENT_CALLBACK_TYPE type, FMOD.Studio.EventInstance instance, System.IntPtr parameterPtr)
    {
        if (type == FMOD.Studio.EVENT_CALLBACK_TYPE.TIMELINE_MARKER)
        {
            var parameter = (FMOD.Studio.TIMELINE_MARKER_PROPERTIES)System.Runtime.InteropServices.Marshal.PtrToStructure(parameterPtr, typeof(FMOD.Studio.TIMELINE_MARKER_PROPERTIES));
            UnityEngine.Debug.LogFormat("Marker: {0}", (string)parameter.name);
        }

        return FMOD.RESULT.OK;
    }

    // Start is called before the first frame update
    void Start()
    {
        FMOD.Studio.EventDescription desc = FMODUnity.RuntimeManager.GetEventDescription("event:/Parent");
        desc.createInstance(out _musicEventInstance);
        
        _musicFmodCallback = new FMOD.Studio.EVENT_CALLBACK(FMODEventCallback);

        _musicEventInstance.setCallback(_musicFmodCallback, FMOD.Studio.EVENT_CALLBACK_TYPE.TIMELINE_BEAT | FMOD.Studio.EVENT_CALLBACK_TYPE.TIMELINE_MARKER);

        _musicEventInstance.start();
    }

    // Update is called once per frame
    void Update()
    {
        
    }
}

```

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/4/41ce55bd063cc3fe19d8f4832f3ca4428c94acd1.png)

---

<div class="post-metadata">

**Author:** ![BadDreamGames](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/baddreamgames/32/1581_2.png) [@BadDreamGames](https://qa.fmod.com/u/BadDreamGames)\
**Post date:** [October 9, 2020, 8:19pm UTC](https://qa.fmod.com/t/get-timeline-marker-callbacks-from-referenced-events/16233/11 "2020-10-09T20:19:48Z")

</div>

Hey Mathew & Tristan! After making some changes I got it working as expected, but to be honest I’m not quite sure where the issue was. I’ll post again when I pin-point the problem.
