# EventDescription length always zero

**URL:** <https://qa.fmod.com/t/eventdescription-length-always-zero/20638>\
**Category:** Unity\
**Tags:** unity, csharp\
**Created:** [September 9, 2023, 3:53pm UTC](https://qa.fmod.com/t/eventdescription-length-always-zero/20638 "2023-09-09T15:53:35Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Giovarco](https://avatars.discourse-cdn.com/v4/letter/g/3ec8ea/32.png) [@Giovarco](https://qa.fmod.com/u/Giovarco)\
**Post date:** [September 9, 2023, 3:53pm UTC](https://qa.fmod.com/t/eventdescription-length-always-zero/20638/1 "2023-09-09T15:53:35Z")

</div>

Hello,

I’m new to FMOD and I’m working on a game with Unity.

I created Single Event and then an Action Sheet, then I dragged and dropped an audio track there.

Screenshot:

 ![Capture](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/d/d9a94bb2fa8ccdde29796dd7f7d187a2754e7c25.png)

This audio track is in this case a piece of a dialogue, e.g. a sentence of many.

Every audio has a text and I need to delete the current text in my UI when the current audio track is finished, and then go next…

This is the class handling some of this logic:

```auto
tnamespace Assets.Scripts.UI.Dialogues
{
    public class DialogPanelView : IDialogueView
    {
        // From constructor
        private GameObject dialogPanelPrefab;
        private Transform canvasTransform;
        private DialogSegmentData dialogSegmentData;

        // Others
        private GameObject instantiatedDialogPanel;

        public DialogPanelView(GameObject dialogPanelPrefab, Transform canvasTransform, DialogSegmentData dialogSegmentData)
        {
            this.dialogPanelPrefab = dialogPanelPrefab ?? throw new ArgumentNullException(nameof(dialogPanelPrefab));
            this.canvasTransform = canvasTransform ?? throw new ArgumentNullException(nameof(canvasTransform));
            this.dialogSegmentData = dialogSegmentData ?? throw new ArgumentNullException(nameof (dialogSegmentData));
        }

        public void Create()
        {
            GameObject dialogPanel = GameObject.Instantiate(dialogPanelPrefab);
            TMP_Text panelText = ComponentUtils.RequireFirstComponentInChildren<TMP_Text>(dialogPanel);
            panelText.text = dialogSegmentData.text;

            dialogPanel.transform.SetParent(canvasTransform, false);

            instantiatedDialogPanel = dialogPanel;
            RuntimeManager.PlayOneShot(dialogSegmentData.soundEvent);
        }

        public float GetWaitingTimeSeconds()
        {
            // TODO
        }

        public void Destroy()
        {
            GameObject.Destroy(instantiatedDialogPanel);
        }

    }
}

```

I want to implement the method _float GetWaitingTimeSeconds()_ but it seems to return zero all the times.

I tried this:

```auto
            EventDescription eventDescription = RuntimeManager.GetEventDescription(dialogSegmentData.soundEvent);
            int totalTime;
            eventDescription.getLength(out totalTime);
            Debug.Log(totalTime);
            return totalTime;

```

And then this:

```auto
EventInstance instance = RuntimeManager.CreateInstance(dialogSegmentData.soundEvent);
            instance.getDescription(out EventDescription eventDescription);

            instance.start();

            int currentTime;
            FMOD.RESULT res = instance.getTimelinePosition(out currentTime);

            if (res != FMOD.RESULT.OK)
            {
                Debug.LogError("getTimelinePosition reported error: " + res);
            }
            Debug.Log($"currentTime = {currentTime}");

            int totalTime;
            FMOD.RESULT res2 = eventDescription.getLength(out totalTime);
            if (res2 != FMOD.RESULT.OK)
            {
                Debug.LogError("getLength reported error: " + res2);
            }
            Debug.Log($"totalTime = {totalTime}");
            return totalTime;

```

But no luck. Clearly I’m making a mistake. I know that this could be due to the fact that “there’s nothing in the timeline”, I’ve read in other threads. And while I understand the idea behind it, I don’t get how to properly implement this.

If you couldhelp me with the implementation of the method and give a brief explaination, I would be grateful.

---

<div class="post-metadata">

**Author:** ![Leah\_FMOD](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/leah_fmod/32/3685_2.png) [@Leah\_FMOD](https://qa.fmod.com/u/Leah_FMOD)\
**Post date:** [September 12, 2023, 2:01am UTC](https://qa.fmod.com/t/eventdescription-length-always-zero/20638/2 "2023-09-12T02:01:41Z")

</div>

Hi,

The issue here is indeed that the timeline is empty - [`Studio::EventDescription::getLength`](https://www.fmod.com/docs/2.02/api/studio-api-eventdescription.html#studio_eventdescription_getlength) specifically returns the length of the timeline, but the event pictured has no timeline, and your asset is being played using an Action Sheet. While there are ways to get the length of the asset currently playing on an Aseets sheet, or to receive a callback when an instrument in an event has stopped playing, they are both more code-heavy than simply moving your single asset to a timeline, so I would recommend doing that if possible.

If using a timeline doesn’t fit for your use-case (e.g. if you’re planing on playing multiple dialogue assets using a single event), can you please provide me with a little more detail on your implementation of this audio behavior in FMOD Studio?

---

<div class="post-metadata">

**Author:** ![Giovarco](https://avatars.discourse-cdn.com/v4/letter/g/3ec8ea/32.png) [@Giovarco](https://qa.fmod.com/u/Giovarco)\
**Post date:** [September 20, 2023, 6:37am UTC](https://qa.fmod.com/t/eventdescription-length-always-zero/20638/3 "2023-09-20T06:37:42Z")

</div>

Hi, thanks for the answer!

How do I actually do what you say? That is, “moving the track to the timeline”, play it and get the length in seconds.

Regarding assets, no only one character at the time will speak. Does that answer your question?

---

<div class="post-metadata">

**Author:** ![Leah\_FMOD](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/leah_fmod/32/3685_2.png) [@Leah\_FMOD](https://qa.fmod.com/u/Leah_FMOD)\
**Post date:** [September 20, 2023, 11:32pm UTC](https://qa.fmod.com/t/eventdescription-length-always-zero/20638/4 "2023-09-20T23:32:40Z")

</div>

> [@Giovarco](#):
>
> How do I actually do what you say? That is, “moving the track to the timeline”, play it and get the length in seconds.

If you click the + button next to the “Actions” tab in your event, you’ll be able to select “Add Timeline Sheet”. This will create a sheet on the event that uses the “Timeline” parameter of the event, which is a fancy way of saying it advances with the passage of time, triggering instruments that the playback position overlaps with. Since [`Studio::EventDescription::getLength`](https://www.fmod.com/docs/2.02/api/studio-api-eventdescription.html#studio_eventdescription_getlength) returns the last point on the timeline with any sort of content, placing your asset on the timeline will cause the function to return the length of the asset. You can then remove the Action sheet from the event by right clicking on the “Actions” tab and selecting “Remove Sheet”.

For more info of Timeline Sheets, please take a look at the [FMOD Studio Glossary entry on Timeline Sheets](https://www.fmod.com/docs/2.02/studio/glossary.html#timeline-sheet).

> [@Giovarco](#):
>
> Regarding assets, no only one character at the time will speak. Does that answer your question?

The more relevant question is whether you’ll be playing a single asset in each event, or whether you want to be able to play more than one asset in a single event, because using `Studio::EventDescription::getLength` in the manner we’re discussing doesn’t work with the latter.
