Hi there!
I’m trying to generate Movie Sequences from C++ from a dialog that I created as a custom asset. I want to call an event everytime a new Dialog Line is supposed to be displayed so I can print the adequate subtitle on screen at the right time.
So far I’ve managed to create sequences, event tracks and event keys from C++. My problem come when I want to send the right data to these event keys. From the editor, the keys only accept blueprint created struct, when I try to use mine, I can’t edit anything and the struct is not carried by the event.
Has someone ever done something like that and can help me my last option if this does not work is to create my own event track but I’m not sure that it will be easy ^^’.
Here is the code I use :
// Adds an event track and section
UMovieSceneEventTrack* EventTrack = CurrentSequence->MovieScene->AddMasterTrack<UMovieSceneEventTrack>();
check(EventTrack);
UMovieSceneSection* NewSection = NewObject<UMovieSceneSection>(EventTrack, UMovieSceneEventSection::StaticClass(), NAME_None, RF_Transactional);
UMovieSceneEventSection* EventSection = Cast<UMovieSceneEventSection>(NewSection);
check(EventSection);
EventTrack->AddSection(*EventSection);
EventTrack->SetDisplayName(LOCTEXT("TrackName", "Events"));
// Get the event section's data to populate with keys
FMovieSceneEventSectionData* EventChannel = EventSection->GetChannelProxy().GetChannel<FMovieSceneEventSectionData>(0);
TMovieSceneChannelData<FEventPayload> EventData = EventChannel->GetData();
for (int i = 0; i < DialogToGenerate->GetNumberOfLines(); ++i)
{
// create an event for this line, giving the speaker and text to the UI
FEventPayload Payload;
Payload.EventName = "SEQ_DisplayLine";
//UDialogEventParams EventParams;
PayloadProperty = NewObject<UDialogEventParams>(this, UDialogEventParams::StaticClass(), *FString("Sentence"), EObjectFlags::RF_Public);
PayloadProperty->Parameters.DialogLine = FText::FromString("A line I want to display on screen!");
PayloadProperty->PrepareCppStructOps();
FMovieSceneEventParameters Params;
Params.Reassign(PayloadProperty);
Payload.Parameters = Params;
//TODO : get the audio time to set the keyframe
EventData.AddKey(i * 48000, Payload);
}
Thanks in advance to anyone able to help here