本文使用关卡动画回调为例
FString assetsPath = "你的路径";
FStringAssetReference sequenceName(assetsPath);
ULevelSequence* sequenceAsset = Cast<ULevelSequence>(sequenceName.TryLoad());
ALevelSequenceActor* currentLevelSequenceActor = nullptr;
ULevelSequencePlayer* sequencePlayer = ULevelSequencePlayer::CreateLevelSequencePlayer(GetWorld(), sequenceAsset, FMovieSceneSequencePlaybackSettings(), currentLevelSequenceActor);
UFUNCTION()
void OnFinished();
ULevelSequencePlayer* nowLSPlayer = nullptr;
.cpp中的实现
void ALevelSequenceManager::OnFinished()
{
UE_LOG(LogTemp, Warning, TEXT("Finish结束了"));
}
OnFinishedDelegate.BindUFunction(this,STATIC_FUNCTION_FNAME(TEXT("ALevelSequenceItem::OnFinished")));
sequencePlayer->OnFinished.Add(OnFinishedDelegate);