UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
WidgetComponent.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "CoreMinimal.h"
9#include "WorldCollision.h"
12#include "WidgetComponent.generated.h"
13
14class FHittestGrid;
16class FWidgetRenderer;
17class SVirtualWindow;
18class SWindow;
19class UBodySetup;
22
23UENUM(BlueprintType)
25{
27 World,
29 Screen
30};
31
32UENUM(BlueprintType)
40
41UENUM(BlueprintType)
43{
44 Opaque,
45 Masked,
47};
48
49UENUM(BlueprintType)
51{
53 Plane,
54
57};
58
59UENUM(BlueprintType)
68
69UENUM(BlueprintType)
71{
74
76 Enabled,
77
80};
81
82
93UCLASS(Blueprintable, ClassGroup="UserInterface", hidecategories=(Object,Activation,"Components|Activation",Sockets,Base,Lighting,LOD,Mesh), editinlinenew, meta=(BlueprintSpawnableComponent) , MinimalAPI)
95{
97
98public:
99 //UObject interface
101 UMG_API virtual bool CanBeInCluster() const override;
103 //~ End UObject Interface
104
106 UMG_API virtual void BeginPlay() override;
107 UMG_API virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override;
108
109 /* UPrimitiveComponent Interface */
110 UMG_API virtual FPrimitiveSceneProxy* CreateSceneProxy() override;
111 UMG_API virtual FBoxSphereBounds CalcBounds(const FTransform & LocalToWorld) const override;
112 UMG_API virtual UBodySetup* GetBodySetup() override;
113 UMG_API virtual FCollisionShape GetCollisionShape(float Inflation) const override;
114 UMG_API virtual void OnRegister() override;
115 UMG_API virtual void OnUnregister() override;
116 UMG_API virtual void DestroyComponent(bool bPromoteChildren = false) override;
117 UMG_API UMaterialInterface* GetMaterial(int32 MaterialIndex) const override;
118 UMG_API virtual void SetMaterial(int32 ElementIndex, UMaterialInterface* Material) override;
119 UMG_API int32 GetNumMaterials() const override;
120 UMG_API virtual void TickComponent(float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
122
123
124 UMG_API virtual TStructOnScope<FActorComponentInstanceData> GetComponentInstanceData() const override;
125 UMG_API void ApplyComponentInstanceData(struct FWidgetComponentInstanceData* ComponentInstanceData);
127
128#if WITH_EDITOR
129 UMG_API virtual bool CanEditChange(const FProperty* InProperty) const override;
130 UMG_API virtual void PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) override;
131#endif
132
134 UMG_API virtual void InitWidget();
135
137 UMG_API virtual void ReleaseResources();
138
140 UMG_API virtual void UpdateWidget();
141
144
149 UMG_API void UpdateBodySetup( bool bDrawSizeChanged = false );
150
153
160
168
171 {
172 return LastLocalHitLocation;
173 }
174
176 TSubclassOf<UUserWidget> GetWidgetClass() const { return WidgetClass; }
177
179 UFUNCTION(BlueprintCallable, Category=UserInterface, meta=(UnsafeDuringActorConstruction=true))
181
183 UMG_API const TSharedPtr<SWidget>& GetSlateWidget() const;
184
187
190
192 UFUNCTION(BlueprintCallable, Category=UserInterface)
193 UMG_API UTextureRenderTarget2D* GetRenderTarget() const;
194
196 UFUNCTION(BlueprintCallable, Category=UserInterface)
197 UMG_API UMaterialInstanceDynamic* GetMaterialInstance() const;
198
201
205 UFUNCTION(BlueprintCallable, Category=UserInterface)
206 UMG_API virtual UUserWidget* GetWidget() const;
207
212 UFUNCTION(BlueprintCallable, Category=UserInterface)
214
220
226 UFUNCTION(BlueprintCallable, Category=UserInterface)
227 UMG_API void SetOwnerPlayer(ULocalPlayer* LocalPlayer);
228
230 UFUNCTION(BlueprintCallable, Category = UserInterface)
231 bool GetManuallyRedraw() const
232 {
233 return bManuallyRedraw;
234 };
235
237 UFUNCTION(BlueprintCallable, Category=UserInterface)
239
241 UFUNCTION(BlueprintCallable, Category=UserInterface)
243
245 UFUNCTION(BlueprintCallable, Category=UserInterface)
246 UMG_API FVector2D GetDrawSize() const;
247
249 UFUNCTION(BlueprintCallable, Category = UserInterface)
251
253 UFUNCTION(BlueprintCallable, Category=UserInterface)
255
257 UFUNCTION(BlueprintCallable, Category=UserInterface, meta = (DeprecatedFunction, DeprecationMessage = "Use RequestRenderUpdate instead"))
259
261 UFUNCTION(BlueprintCallable, Category = UserInterface)
263
265 EWidgetBlendMode GetBlendMode() const { return BlendMode; }
266
268 UMG_API void SetBlendMode( const EWidgetBlendMode NewBlendMode );
269
271 UFUNCTION(BlueprintCallable, Category = Rendering)
272 bool GetTwoSided() const
273 {
274 return bIsTwoSided;
275 };
276
278 UFUNCTION(BlueprintCallable, Category = Rendering)
279 UMG_API void SetTwoSided( const bool bWantTwoSided );
280
282 UFUNCTION(BlueprintCallable, Category = Animation)
283 bool GetTickWhenOffscreen() const
284 {
285 return TickWhenOffscreen;
286 };
287
289 UFUNCTION(BlueprintCallable, Category = Animation)
291 {
293 };
294
296 UFUNCTION(BlueprintCallable, Category=UserInterface)
297 UMG_API void SetBackgroundColor( const FLinearColor NewBackgroundColor );
298
300 UFUNCTION(BlueprintCallable, Category=UserInterface)
302
305
307 UFUNCTION(BlueprintCallable, Category = UserInterface)
308 FVector2D GetPivot() const { return Pivot; }
309
311 UFUNCTION(BlueprintCallable, Category = UserInterface)
312 void SetPivot( const FVector2D& InPivot ) { Pivot = InPivot; }
313
315 UFUNCTION(BlueprintCallable, Category = UserInterface)
316 bool GetDrawAtDesiredSize() const { return bDrawAtDesiredSize; }
317
319 UFUNCTION(BlueprintCallable, Category = UserInterface)
321
323 UFUNCTION(BlueprintCallable, Category = UserInterface)
324 float GetRedrawTime() const { return RedrawTime; }
325
327 UFUNCTION(BlueprintCallable, Category = UserInterface)
329
332
335
338
339 UFUNCTION(BlueprintCallable, Category = UserInterface)
340 EWidgetSpace GetWidgetSpace() const { return Space; }
341
342 UFUNCTION(BlueprintCallable, Category = UserInterface)
344
345 bool GetEditTimeUsable() const { return bEditTimeUsable; }
346
348
350 UFUNCTION(BlueprintCallable, Category = UserInterface)
352 {
353 return GeometryMode;
354 }
355
356 UFUNCTION(BlueprintCallable, Category = UserInterface)
358 {
359 GeometryMode = InGeometryMode;
360 }
361
362 bool GetReceiveHardwareInput() const { return bReceiveHardwareInput; }
363
365 UFUNCTION(BlueprintCallable, Category = UserInterface)
366 double GetCylinderArcAngle() const { return CylinderArcAngle; }
367
369 UFUNCTION(BlueprintCallable, Category = UserInterface)
370 void SetCylinderArcAngle(const double InCylinderArcAngle)
371 {
373 }
374
375
378
381
383 UFUNCTION(BlueprintCallable, Category = UserInterface)
384 bool GetWindowFocusable() const
385 {
386 return bWindowFocusable;
387 };
388
390 UFUNCTION(BlueprintCallable, Category = UserInterface)
392
394 UFUNCTION(BlueprintCallable, Category = UserInterface)
396 {
397 return WindowVisibility;
398 }
399
401 UFUNCTION(BlueprintCallable, Category = UserInterface)
402 UMG_API void SetWindowVisibility(EWindowVisibility InVisibility);
403
405 UFUNCTION(BlueprintCallable, Category = UserInterface)
407
409 UFUNCTION(BlueprintCallable, Category = UserInterface)
410 UMG_API bool IsWidgetVisible() const;
411
413 virtual FVector2D ModifyProjectedLocalPosition(const FGeometry& ViewportGeometry, const FVector2D& LocalPosition) { return LocalPosition; }
414
417
418protected:
419 UMG_API void OnLevelRemovedFromWorld(ULevel* InLevel, UWorld* InWorld);
420
422 UMG_API bool CanReceiveHardwareInput() const;
423
426
427 UMG_API void RegisterWindow();
430
432 UMG_API virtual bool ShouldDrawWidget() const;
433
435 UMG_API virtual void DrawWidgetToRenderTarget(float DeltaTime);
436
438 UMG_API double ComputeComponentWidth() const;
439
441
442 UMG_API virtual void OnHiddenInGameChanged() override;
443
444protected:
446 UPROPERTY(EditAnywhere, Category=UserInterface)
448
450 UPROPERTY(EditAnywhere, Category=UserInterface)
452
454 UPROPERTY(EditAnywhere, Category=UserInterface)
455 TSubclassOf<UUserWidget> WidgetClass;
456
458 UPROPERTY(EditAnywhere, Category=UserInterface)
459 FIntPoint DrawSize;
460
462 UPROPERTY(EditAnywhere, Category=UserInterface)
463 bool bManuallyRedraw;
464
466 UPROPERTY(Transient, DuplicateTransient)
467 bool bRedrawRequested;
468
474 UPROPERTY(EditAnywhere, Category=UserInterface)
475 float RedrawTime;
476
479
481 UMG_API double GetCurrentTime() const;
482
487 UPROPERTY(Transient, DuplicateTransient)
489
494 UPROPERTY(EditAnywhere, Category = UserInterface, meta=(EditCondition="Space==EWidgetSpace::World", DisplayName="Use Invalidation"))
496
504 UPROPERTY(EditAnywhere, Category=UserInterface)
506
508 UPROPERTY(EditAnywhere, Category=UserInterface)
509 FVector2D Pivot;
510
521 UPROPERTY(EditAnywhere, Category=Interaction)
523
525 UPROPERTY(EditAnywhere, Category=Interaction)
526 bool bWindowFocusable;
527
529 UPROPERTY(EditAnywhere, Category = Interaction)
531
536 UPROPERTY(EditAnywhere, Category = UserInterface, AdvancedDisplay)
538
543 UPROPERTY()
545
547 UPROPERTY(EditAnywhere, Category=Rendering)
548 FLinearColor BackgroundColor;
549
551 UPROPERTY(EditAnywhere, Category=Rendering)
553
555 UPROPERTY(EditAnywhere, Category=Rendering, meta=(ClampMin=0.0f, ClampMax=1.0f))
556 float OpacityFromTexture;
557
559 UPROPERTY(EditAnywhere, Category=Rendering)
560 EWidgetBlendMode BlendMode;
561
563 UPROPERTY(EditAnywhere, Category=Rendering)
564 bool bIsTwoSided;
565
567 UPROPERTY(EditAnywhere, Category=Animation)
569
571 UPROPERTY(Transient, DuplicateTransient)
573
575 UPROPERTY()
577
579 UPROPERTY()
581
583 UPROPERTY()
585
587 UPROPERTY()
589
591 UPROPERTY()
593
595 UPROPERTY()
597
599 UPROPERTY(Transient, DuplicateTransient)
601
603 UPROPERTY(Transient, DuplicateTransient)
605
606 UPROPERTY(Transient, DuplicateTransient)
607 bool bAddedToScreen;
608
612 UPROPERTY()
613 bool bEditTimeUsable;
614
616
618 UPROPERTY(EditDefaultsOnly, Category = Layers)
620
622 UPROPERTY(EditDefaultsOnly, Category = Layers)
624
626 UPROPERTY(EditAnywhere, Category=UserInterface)
627 EWidgetGeometryMode GeometryMode;
628
630 UPROPERTY(EditAnywhere, Category=UserInterface, meta=(ClampMin=1.0f, ClampMax=180.0f))
631 double CylinderArcAngle;
632
633 UPROPERTY(EditAnywhere, Category = UserInterface)
635
638
640 FVector2D LastLocalHitLocation;
641
644
646 class FWidgetRenderer* WidgetRenderer;
647
648private:
650
652 UPROPERTY(Transient, DuplicateTransient)
654
657
660
663
665
667
670
673
676
678 bool bRenderCleared;
680};
681
682USTRUCT()
684{
686public:
690
692 : FSceneComponentInstanceData(SourceComponent)
693 , WidgetClass(SourceComponent->GetWidgetClass())
694 , RenderTarget(SourceComponent->GetRenderTarget())
695 {}
696 virtual ~FWidgetComponentInstanceData() = default;
697
698 virtual bool ContainsData() const override
699 {
700 return true;
701 }
702
704 {
705 Super::ApplyToComponent(Component, CacheApplyPhase);
706 CastChecked<UWidgetComponent>(Component)->ApplyComponentInstanceData(this);
707 }
708
709 virtual void AddReferencedObjects(FReferenceCollector& Collector) override
710 {
711 Super::AddReferencedObjects(Collector);
712
713 Collector.AddReferencedObject(WidgetClass.GetGCPtr());
714 Collector.AddReferencedObject(RenderTarget);
715 }
716
717public:
720};
ECacheApplyPhase
Definition ComponentInstanceDataCache.h:18
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
#define DECLARE_MULTICAST_DELEGATE(DelegateName)
Definition DelegateCombinations.h:23
ELevelTick
Definition EngineBaseTypes.h:70
const bool
Definition NetworkReplayStreaming.h:178
#define UPROPERTY(...)
UObject definition macros.
Definition ObjectMacros.h:744
#define GENERATED_BODY(...)
Definition ObjectMacros.h:765
#define UFUNCTION(...)
Definition ObjectMacros.h:745
#define GENERATED_UCLASS_BODY(...)
Definition ObjectMacros.h:768
#define UCLASS(...)
Definition ObjectMacros.h:776
#define UENUM(...)
Definition ObjectMacros.h:749
#define USTRUCT(...)
Definition ObjectMacros.h:746
@ UpdateBodySetup
Definition BoxComponent.cpp:94
ESlateVisibility
Definition SlateWrapperTypes.h:22
uint32 Size
Definition VulkanMemory.cpp:4034
EWidgetGeometryMode
Definition WidgetComponent.h:51
EWidgetSpace
Definition WidgetComponent.h:25
EWindowVisibility
Definition WidgetComponent.h:61
ETickMode
Definition WidgetComponent.h:71
EWidgetBlendMode
Definition WidgetComponent.h:43
EWidgetTimingPolicy
Definition WidgetComponent.h:34
uint8_t uint8
Definition binka_ue_file_header.h:8
Definition Archive.h:1208
Definition HittestGrid.h:30
Definition NameTypes.h:617
Definition PrimitiveSceneProxy.h:296
Definition UnrealType.h:174
Definition UObjectGlobals.h:2492
Definition WidgetComponent.cpp:154
Definition WidgetRenderer.h:29
Definition SVirtualWindow.h:22
Definition SWidget.h:165
Definition SWindow.h:243
Definition Sockets.Build.cs:6
Definition Array.h:670
Definition SharedPointer.h:692
Definition StructOnScope.h:142
Definition SubclassOf.h:30
TObjectPtr< UClass > & GetGCPtr()
Definition SubclassOf.h:167
Definition SharedPointer.h:1295
Definition ActorComponent.h:152
Definition BodySetup.h:128
Definition Level.h:423
Definition LocalPlayer.h:169
Definition MaterialInstanceDynamic.h:15
Definition MaterialInterface.h:296
Definition MeshComponent.h:25
Definition TextureRenderTarget2D.h:104
Definition UserWidget.h:284
Definition World.h:918
Definition EngineTypes.h:3429
@ false
Definition radaudio_common.h:23
Definition Visibility.h:12
Definition ComponentInstanceDataCache.h:149
Definition EngineBaseTypes.h:571
Definition CollisionShape.h:21
Definition Geometry.h:40
Definition Color.h:48
Definition PSOPrecache.h:30
Definition UnrealType.h:6865
Definition SceneComponent.h:1743
Definition ArrangedWidget.h:66
Definition WidgetComponent.h:684
virtual void ApplyToComponent(UActorComponent *Component, const ECacheApplyPhase CacheApplyPhase) override
Definition WidgetComponent.h:703
FWidgetComponentInstanceData()
Definition WidgetComponent.h:687
virtual void AddReferencedObjects(FReferenceCollector &Collector) override
Definition WidgetComponent.h:709
TSubclassOf< UUserWidget > WidgetClass
Definition WidgetComponent.h:718
virtual ~FWidgetComponentInstanceData()=default
virtual bool ContainsData() const override
Definition WidgetComponent.h:698
TObjectPtr< UTextureRenderTarget2D > RenderTarget
Definition WidgetComponent.h:719
FWidgetComponentInstanceData(const UWidgetComponent *SourceComponent)
Definition WidgetComponent.h:691
Definition ObjectPtr.h:488
Definition Tuple.h:652
Definition BoxSphereBounds.h:25
Definition IntPoint.h:25