Hello,
I’m currently working on replicating a video editing timeline in Unity. The goal is to be able to preview the cinematics of my video game directly with Unity’s editor. With this tool, I aim to avoid the back-and-forth between “cinematic editing” and “launching the game with the play button,” which consumes a lot of time during cinematic design.
Here’s a screenshot of the preview of my functional timeline.
In our project, we use FMOD, and I’m attempting to enable sound preview via my timeline, similar to a video editing software. I’ve managed to play the sound preview in the editor by using the PreviewEvent() function from the EditorUtils script, thus synchronizing the visual of my timeline with the preview. So, when the timeline cursor enters a sound block, the sound plays.
Now, I’m trying to move on to the second step: playing the sound at a certain given time. For this, I’ve consulted the documentation on your website as well as some posts on the forum:
FMOD doc
How to use settimelineposition ?
All the links provided suggest using the method: SetTimeLinePosition(), however, this doesn’t seem to work in my situation. In the search for a solution, I’ve written a simple script completely detached from my timeline to test if the method works. Here’s the script:
using UnityEngine;
using FMODUnity;
public class Test : MonoBehaviour
{
public EventReference fmodEvent;
public bool paused;
private FMOD.Studio.EventInstance eventInstance;
void Start()
{
GetComponent<FMODUnity.StudioEventEmitter>().Play();
eventInstance = GetComponent<FMODUnity.StudioEventEmitter>().EventInstance;
}
void Update()
{
if (Input.GetKeyDown(KeyCode.UpArrow))
{
eventInstance.stop(FMOD.Studio.STOP_MODE.IMMEDIATE);
paused = true;
}
if (Input.GetKeyUp(KeyCode.UpArrow) && paused)
{
paused = false;
eventInstance.setTimelinePosition(1500);
eventInstance.getTimelinePosition(out int currentPosition);
Debug.Log(currentPosition);
eventInstance.start();
}
}
}
As you can see, I’ve added a Debug.Log to verify if the setTimelinePosition() method executes correctly, and its result is 0. The method did not position the timeline at 1500 milliseconds.
After many hours of research and with the limited resources available for developers on the FMOD tool, I can’t find any solution. Did I use the method correctly? Did I forget to do something? Can anyone help me?