Bug?: Functionality regarding timeline doesn't work if the timeline is not present in the editor
Hello everyone!
I've made a short video displaying my issue/potential bug.
I'm having quite some issues regarding what I think to be a bug in Unity. Whenever enter playmode with the timeline present in my editor, everything works fine, but when I enter playmode without the Timeline present in any of my editor windows (or if i'm in maximize on play), any functionality regarding the green timeline track clips specifically fails to be executed. If I open the timeline during playtime, all functionality is restored. The big issue is though is that in my build the same issue occurs. The green timeline track is one generated in a script. It generates one of those preview clips (the blue or yellow semi-circles) for every yellow clip present on the timeline. Considering it's only the functionality of the green track that is affected, it probably has to do something with fact that I generate that track, but then that still wouldn't be able to explain why it works fine only when the timeline is present in the editor.
Here is where I generate the track. This function is called in the awake function.
private void CreatePreviewTrack()
{
var rootTracks = timeline.GetRootTracks();
foreach (var track in rootTracks)
{
if (track is NoteControlTrack)
{
var trackClips = track.GetClips();
foreach (var clip in trackClips)
{
NoteControlClip noteControlClip = clip.asset as NoteControlClip;
previewNotes.Add(new NotePreviewData(clip.start - previewDuration, previewDuration, noteControlClip.noteType));
}
}
}
previewTrack = timeline.CreateTrack<NotePreviewTrack>();
timeLineObj.SetGenericBinding(previewTrack, this.gameObject);
foreach (NotePreviewData clipData in previewNotes)
{
TimelineClip clip = previewTrack.CreateClip<NotePreviewClip>();
NotePreviewClip notePreviewClip = clip.asset as NotePreviewClip;
clip.start = clipData.startTime;
clip.duration = clipData.duration;
notePreviewClip.noteType = clipData.type;
}
TimelineEditor.Refresh(RefreshReason.ContentsAddedOrRemoved);
}
And here is what the timeclips are supposed to do:
public class NotePreviewBehaviour : PlayableBehaviour
{
public NoteType type;
public override void OnBehaviourPlay(Playable playable, FrameData info)
{
NotePreview.Instance.InstantiateNotePreview(type);
Debug.Log(type);
base.OnBehaviourPlay(playable, info);
}
}
It could be that I'm just doing something drastically wrong regarding working with the timeline, this is the first time i ever attempted something like this. Any help would be greatly appreciated!
Answer by DavidGeoffroy · May 06, 2021 at 01:35 PM
There's nothing wrong that I can see in the code you posted, but there may be something else in the rest of the code.
Please submit a bug report containing a scene that reproduces your issue, and we will look at it promptly.
You can use the bug reporter to report your bug.