UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
SubtitlesAndClosedCaptionsDelegates.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
6#include "SubtitlesAndClosedCaptionsDelegates.generated.h"
7
8#define UE_API ENGINE_API
9
10class FCanvas;
11class UAssetUserData;
12
13// Externally-Timed subtitles must be manually added and removed with USubtitlesSubsystem::QueueSubtitle and ::StopSubtitle.
14// For the initial delay before becoming visible, use USubtitleAssetUserData::StartOffset instead of this enum.
15UENUM()
21
22// SubtitlesAudioSubsystem will automatically queue and stop subtitles embedded in USoundBase sounds using play/stop callbacks.
23// This enum controls whether the stopping should be done automatically, or if the subtitle should be timed using its existing duration.
24UENUM(BlueprintType)
26{
27 UseSoundDuration UMETA(ToolTip = "Automatically stops this subtitle when the sound stops playing (only useful when attached as AssetUserData"),
28 UseDurationProperty UMETA(ToolTip = "Time this subtitle using its Duration property")
29};
30
31// Subtitle type for type-specific rendering.
32UENUM()
39
40// Minimum duration to display subtitle.
41static constexpr float SubtitleMinDuration = 0.05f;
42
43// Default value to initialize subtitle duration to. Used by SoundWaves to check if they should manually set the duration.
44static constexpr float SubtitleDefaultDuration = 3.f;
45
46USTRUCT(MinimalAPI, BlueprintType)
48{
50
51 // #SUBTITLES_PRD: carried over from FSubtitleCue, still required
52
53 // The text to appear in the subtitle.
54 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Subtitles", meta = (Multiline = true))
56
57 // #SUBTITLES_PRD: carried over from FSubtitleCue, still required
58
59 // Whether to automatically unqueue the subtitle using an associated Sound, or to use the duration supplied below.
60 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Subtitles|Duration")
62
63#if WITH_EDITORONLY_DATA
64 // Editor-only helper value for SubtitleDefaultDuration's EditCondition.
66 bool bCanEditDuration = (SubtitleDurationType == ESubtitleDurationType::UseDurationProperty);
67#endif
68
69 // Time to display in seconds.
70 // Defaulted to 3 seconds so when adding new subtitles it's not required to enter a placeholder Duration.
71 // Duration can be be set by ingestion pipelines when importing Subtitles in bulk
72 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Subtitles|Duration", meta = (ClampMin = 0.05f, EditCondition = "bCanEditDuration"))
73 float Duration = SubtitleDefaultDuration;
74
75 // Some subtitles have a delay before they're allowed to be displayed (primarily from the legacy system).
76 // StartOffset measures how long in Seconds, after queuing, before the subtitle is allowed to enter the active subtitles queue.
77 // ESubtitleTiming::ExternallyTimed does not effect this initial delay.
78 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Subtitles", meta = (ClampMin = 0.f))
79 float StartOffset = 0.f;
80
81 // #SUBTITLES_PRD: Priority comes from USoundBase::GetSubtitlePriority, USoundCue::GetSubtitlePriority and USoundWave::GetSubtitlePriority
82 // Consolidate various subtitle properties throughout sound/audio code into this new subtitles plugin.
83
84 // The priority of the subtitle. Defaults to 1. Higher values will play instead of lower values.
85 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Subtitles")
86 float Priority = 1.f;
87
88 // Subtitle type for type-specific rendering.
89 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Subtitles")
91
92#if WITH_EDITORONLY_DATA
93 // Author comments, editor-only.
94 UPROPERTY(EditAnywhere, Category = "Subtitles")
95 FString Comment;
96#endif // WITH_EDITORONLY_DATA
97
98 // The struct needs a custom equality test operator because FText doesn't have one overloaded: need to use EqualTo().
99 // Don't compare the Comment property because it isn't compiled outside the editor.
100 const bool operator==(const FSubtitleAssetData& Other) const
101 {
102 return ((Text.EqualTo(Other.Text) && (SubtitleDurationType == Other.SubtitleDurationType) && (Duration == Other.Duration)
103 && (StartOffset == Other.StartOffset) && (Priority == Other.Priority) && (SubtitleType == Other.SubtitleType)));
104 }
105};
106
110UCLASS(MinimalAPI, BlueprintType)
112{
114
115public:
116 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Subtitles")
118
119 // In seconds, the longest any subtitle in the Subtitles array will last, including any initial offset starts.
120 float GetMaximumDuration() const
121 {
122 float Duration = 0.f;
123 for (const FSubtitleAssetData& Entry : Subtitles)
124 {
125 const float EntryDuration = Entry.Duration + Entry.StartOffset;
126 Duration = FMath::Max(Duration, EntryDuration);
127 }
128
129 return Duration;
130 };
131
132#if WITH_EDITORONLY_DATA
133 // UObject::PostEditChangeProperty is in a #if WITH_EDITOR wrapper.
134 // EDITORONLY_DATA seems equivalent here and ensures that it matches the #if for bCanEditDuration above (which is indeed editor-only data).
135 virtual void PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) override;
136#endif
137};
138
139
141{
144 TOptional<float> StartOffset; // Scrubbing subtitles in the sequencer needs an override for StartOffset.
145};
146
148{
149public:
150
151 // Have the subtitle subsystem to queue a subtitle to be displayed
153
155
157
159};
160
161#undef UE_API
OODEFFUNC typedef void(OODLE_CALLBACK t_fp_OodleCore_Plugin_Free)(void *ptr)
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
const bool
Definition NetworkReplayStreaming.h:178
#define UPROPERTY(...)
UObject definition macros.
Definition ObjectMacros.h:744
#define GENERATED_BODY(...)
Definition ObjectMacros.h:765
#define UCLASS(...)
Definition ObjectMacros.h:776
#define UENUM(...)
Definition ObjectMacros.h:749
#define USTRUCT(...)
Definition ObjectMacros.h:746
USkinnedMeshComponent float
Definition SkinnedMeshComponent.h:60
ESubtitleTiming
Definition SubtitlesAndClosedCaptionsDelegates.h:17
#define UE_API
Definition SubtitlesAndClosedCaptionsDelegates.h:8
ESubtitleType
Definition SubtitlesAndClosedCaptionsDelegates.h:34
ESubtitleDurationType
Definition SubtitlesAndClosedCaptionsDelegates.h:26
uint8_t uint8
Definition binka_ue_file_header.h:8
Definition CanvasTypes.h:211
Definition SubtitlesAndClosedCaptionsDelegates.h:148
static UE_API TDelegate< bool(const FSubtitleAssetData &)> IsSubtitleActive
Definition SubtitlesAndClosedCaptionsDelegates.h:154
static UE_API TDelegate< void()> StopAllSubtitles
Definition SubtitlesAndClosedCaptionsDelegates.h:158
static UE_API TDelegate< void(const FSubtitleAssetData &)> StopSubtitle
Definition SubtitlesAndClosedCaptionsDelegates.h:156
static UE_API TDelegate< void(const FQueueSubtitleParameters &, const ESubtitleTiming)> QueueSubtitle
Definition SubtitlesAndClosedCaptionsDelegates.h:152
Definition Text.h:385
Definition Array.h:670
Definition DelegateSignatureImpl.inl:310
Definition AssetUserData.h:18
Definition SubtitlesAndClosedCaptionsDelegates.h:112
Definition UnrealType.h:6865
Definition SubtitlesAndClosedCaptionsDelegates.h:141
TOptional< float > Duration
Definition SubtitlesAndClosedCaptionsDelegates.h:143
const FSubtitleAssetData & Subtitle
Definition SubtitlesAndClosedCaptionsDelegates.h:142
TOptional< float > StartOffset
Definition SubtitlesAndClosedCaptionsDelegates.h:144
Definition SubtitlesAndClosedCaptionsDelegates.h:48
const bool operator==(const FSubtitleAssetData &Other) const
Definition SubtitlesAndClosedCaptionsDelegates.h:100
float Duration
Definition SubtitlesAndClosedCaptionsDelegates.h:73
Definition Optional.h:131