UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
UIComponentContainer.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"
7#include "UObject/Object.h"
9
10#include "UIComponentContainer.generated.h"
11
12#define UE_API UMG_API
13
14class UUserWidget;
15class UWidget;
16class UUIComponent;
17class UWidgetTree;
18
19USTRUCT()
21{
23public:
24
27
29 UWidget* Resolve(const class UWidgetTree* WidgetTree);
30 FName GetTargetName() const { return TargetName; }
31 void SetTargetName(FName NewName);
32 UUIComponent* GetComponent() const { return Component; }
33 bool IsValid() const { return !TargetName.IsNone() && Component != nullptr; }
34
35private:
36
37 // We use a TargetName to resolve the Widget only at compile time and on the Runtime Widget.
38 // It simplify edition in UMG Designer and make sure we do not need to keep Association in sync with the WidgetTree.
39 UPROPERTY()
40 FName TargetName;
41
42 UPROPERTY(Instanced)
44};
45
46
50UCLASS(MinimalAPI, NotBlueprintType)
52{
54
55public:
56 UE_API void AddComponent(FName TargetName, UUIComponent* Component);
57 UE_API void RemoveComponent(FName TargetName, UUIComponent* Component);
58 UE_API void RemoveAllComponentsOfType(const UClass* ComponentClass, FName TargetName);
59 UE_API void RemoveAllComponentsFor(FName TargetName);
60
61 UE_API void MoveComponent(FName TargetName, const UClass* ComponentClass, const UClass* RelativeToComponentClass, bool bMoveAfter);
62
63 UE_API UUIComponent* GetComponent(const UClass* ComponentClass, FName TargetName) const;
64
65 UE_API void ForEachComponent(TFunctionRef<void(UUIComponent*)> Predicate) const;
66 UE_API void ForEachComponentTarget(TFunctionRef<void(const FUIComponentTarget&)> Predicate) const;
67
68 UE_API void InitializeComponents(const UUserWidget* UserWidget);
69
70 UE_API bool IsEmpty() const;
71
72 static UE_API FName GetPropertyNameForComponent(const UUIComponent* Component, const FName& TargetName);
73#ifdef WITH_EDITOR
74 UE_API void RenameWidget(const FName& OldName, const FName& NewName);
75 UE_API void CleanupUIComponents(const UWidgetTree* WidgetTree);
76#endif //WITH_EDITOR
77
78private:
79 UPROPERTY()
81};
82
83#undef UE_API
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
#define UPROPERTY(...)
UObject definition macros.
Definition ObjectMacros.h:744
#define GENERATED_BODY(...)
Definition ObjectMacros.h:765
#define UCLASS(...)
Definition ObjectMacros.h:776
#define USTRUCT(...)
Definition ObjectMacros.h:746
#define UE_API
Definition UIComponentContainer.h:12
Definition NameTypes.h:617
Definition Array.h:670
Definition AssetRegistryState.h:50
Definition Class.h:3793
Definition Object.h:95
Definition UIComponentContainer.h:52
Definition UIComponent.h:25
Definition UserWidget.h:284
Definition WidgetTree.h:20
Definition Widget.h:217
Definition UIComponentContainer.h:21
bool IsValid() const
Definition UIComponentContainer.h:33
UUIComponent * GetComponent() const
Definition UIComponentContainer.h:32
FName GetTargetName() const
Definition UIComponentContainer.h:30
Definition ObjectPtr.h:488