Add the option to change the speed of each line displayed

This commit is contained in:
Steve Streeting 2022-09-27 18:10:43 +01:00
parent 6d1df0f90c
commit 68e49d9e92
2 changed files with 3 additions and 3 deletions

View File

@ -60,7 +60,7 @@ FText UTypewriterTextWidget::GetText() const
return FText(); return FText();
} }
void UTypewriterTextWidget::PlayLine(const FText& InLine) void UTypewriterTextWidget::PlayLine(const FText& InLine, float Speed)
{ {
check(GetWorld()); check(GetWorld());
@ -102,7 +102,7 @@ void UTypewriterTextWidget::PlayLine(const FText& InLine)
FTimerDelegate Delegate; FTimerDelegate Delegate;
Delegate.BindUObject(this, &ThisClass::PlayNextLetter); Delegate.BindUObject(this, &ThisClass::PlayNextLetter);
TimerManager.SetTimer(LetterTimer, Delegate, LetterPlayTime, true); TimerManager.SetTimer(LetterTimer, Delegate, LetterPlayTime/Speed, true);
SetVisibility(ESlateVisibility::SelfHitTestInvisible); SetVisibility(ESlateVisibility::SelfHitTestInvisible);
} }

View File

@ -78,7 +78,7 @@ public:
UFUNCTION(BlueprintCallable, Category = "Typewriter") UFUNCTION(BlueprintCallable, Category = "Typewriter")
void PlayLine(const FText& InLine); void PlayLine(const FText& InLine, float Speed = 1.0f);
UFUNCTION(BlueprintCallable, Category = "Typewriter") UFUNCTION(BlueprintCallable, Category = "Typewriter")
void GetCurrentLine(FText& OutLine) const { OutLine = CurrentLine; } void GetCurrentLine(FText& OutLine) const { OutLine = CurrentLine; }