Is it possible to create sequencer event track at runtime with c++ (including in shipping builds)? I’ve been trying to it out but unable to get anywhere. Here’s a code sample that works in the editor (including standalone mode) but not in development or shipping build.
USTRUCT(BlueprintType)
struct FInputParams
{
GENERATED_BODY()
public:
UPROPERTY(EditAnywhere, BlueprintReadWrite)
int32 InputParam;
};
UMovieSceneEventTrack* EventTrack = NewObject<UMovieSceneEventTrack>(this, UMovieSceneEventTrack::StaticClass());
UMovieSceneEventSection* EventSection = NewObject<UMovieSceneEventSection>(EventTrack, UMovieSceneEventSection::StaticClass());
if (!EventSection)
{
UE_LOG(LogTemp, Error, TEXT("Event Section is not valid"));
return;
}
EventTrack->AddSection(*EventSection);
FEventPayload Payload;
Payload.EventName = "CalledFromSequencer"; //Function must be in level blueprint
FInputParams ParamsToPass;
ParamsToPass.InputParam = 7; //Test value
UScriptStruct* PayloadProperty = StaticStruct<FInputParams>();
Payload.Parameters.Reassign(PayloadProperty);
Payload.Parameters.OverwriteWith((uint8*)&ParamsToPass);
FMovieSceneChannelProxy& Proxy = EventSection->GetChannelProxy();
FMovieSceneEventSectionData* Channel = Proxy.GetChannel<FMovieSceneEventSectionData>(0);
if (!Channel)
{
UE_LOG(LogTemp, Error, TEXT("Channel is not valid"));
return;
}
TMovieSceneChannelData<FEventPayload> ChannelData = Channel->GetData();
int32 KeyIndex = ChannelData.AddKey(10 * 1000 /*Adds this key to 10th frame */, Payload);
UE_LOG(LogTemp, Warning, TEXT("Newly added key index: %d"), KeyIndex);
I’ve tried using section of type UMovieSceneEventTriggerSection but I was unable to get the event binding done properly inside editor, let alone in a build. Would really appreciate some help!