UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
FUserWidgetPool Struct Reference

#include <UserWidgetPool.h>

Public Types

using WidgetConstructFunc = TFunctionRef< TSharedPtr< SObjectWidget >(UUserWidget *, TSharedRef< SWidget >)>
 

Public Member Functions

 GENERATED_BODY ()
 
 FUserWidgetPool ()=default
 
UMG_API FUserWidgetPool (UWidget &InOwningWidget)
 
UMG_API ~FUserWidgetPool ()
 
UMG_API void SetWorld (UWorld *OwningWorld)
 
UMG_API void SetDefaultPlayerController (APlayerController *InDefaultPlayerController)
 
UMG_API void RebuildWidgets ()
 
UMG_API void AddReferencedObjects (FReferenceCollector &Collector)
 
bool IsInitialized () const
 
const TArray< UUserWidget * > & GetActiveWidgets () const
 
template<typename UserWidgetT = UUserWidget>
UserWidgetTGetOrCreateInstance (TSubclassOf< UserWidgetT > WidgetClass)
 
template<typename UserWidgetT = UUserWidget>
UserWidgetTGetOrCreateInstance (TSubclassOf< UserWidgetT > WidgetClass, WidgetConstructFunc ConstructWidgetFunc)
 
UMG_API void Release (UUserWidget *Widget, bool bReleaseSlate=false)
 
UMG_API void Release (TArray< UUserWidget * > Widgets, bool bReleaseSlate=false)
 
UMG_API void ReleaseAll (bool bReleaseSlate=false)
 
UMG_API void ResetPool ()
 
UMG_API void ReleaseInactiveSlateResources ()
 
void ReleaseSlateResources ()
 
UMG_API void ReleaseAllSlateResources ()
 

Detailed Description

Pools UUserWidget instances to minimize UObject and SWidget allocations for UMG elements with dynamic entries.

Note that if underlying Slate instances are released when a UserWidget instance becomes inactive, NativeConstruct & NativeDestruct will be called when UUserWidget instances are made active or inactive, respectively, provided the widget isn't actively referenced in the Slate hierarchy (i.e. if the shared reference count on the widget goes from/to 0).

WARNING: Be sure to release the pool's Slate widgets within the owning widget's ReleaseSlateResources call to prevent leaking due to circular references Otherwise the cached references to SObjectWidgets will keep the UUserWidgets - and all that they reference - alive

See also
UListView
UDynamicEntryBox

Member Typedef Documentation

◆ WidgetConstructFunc

Constructor & Destructor Documentation

◆ FUserWidgetPool() [1/2]

FUserWidgetPool::FUserWidgetPool ( )
default

◆ FUserWidgetPool() [2/2]

FUserWidgetPool::FUserWidgetPool ( UWidget InOwningWidget)

◆ ~FUserWidgetPool()

FUserWidgetPool::~FUserWidgetPool ( )

Member Function Documentation

◆ AddReferencedObjects()

void FUserWidgetPool::AddReferencedObjects ( FReferenceCollector Collector)

Report any references to UObjects to the reference collector (only necessary if this is not already a UPROPERTY)

◆ GENERATED_BODY()

FUserWidgetPool::GENERATED_BODY ( )

◆ GetActiveWidgets()

const TArray< UUserWidget * > & FUserWidgetPool::GetActiveWidgets ( ) const
inline

◆ GetOrCreateInstance() [1/2]

template<typename UserWidgetT = UUserWidget>
UserWidgetT * FUserWidgetPool::GetOrCreateInstance ( TSubclassOf< UserWidgetT WidgetClass)
inline

Gets an instance of a widget of the given class. The underlying slate is stored automatically as well, so the returned widget is fully constructed and GetCachedWidget will return a valid SWidget.

◆ GetOrCreateInstance() [2/2]

template<typename UserWidgetT = UUserWidget>
UserWidgetT * FUserWidgetPool::GetOrCreateInstance ( TSubclassOf< UserWidgetT WidgetClass,
WidgetConstructFunc  ConstructWidgetFunc 
)
inline

Gets an instance of the widget this factory is for with a custom underlying SObjectWidget type

◆ IsInitialized()

bool FUserWidgetPool::IsInitialized ( ) const
inline

◆ RebuildWidgets()

void FUserWidgetPool::RebuildWidgets ( )

Triggers RebuildWidget on all currently active UserWidget instances

◆ Release() [1/2]

void FUserWidgetPool::Release ( TArray< UUserWidget * >  Widgets,
bool  bReleaseSlate = false 
)

Return a widget object to the pool, allowing it to be reused in the future

◆ Release() [2/2]

void FUserWidgetPool::Release ( UUserWidget Widget,
bool  bReleaseSlate = false 
)

Return a widget object to the pool, allowing it to be reused in the future

◆ ReleaseAll()

void FUserWidgetPool::ReleaseAll ( bool  bReleaseSlate = false)

Returns all active widget objects to the inactive pool and optionally destroys all cached underlying slate widgets.

◆ ReleaseAllSlateResources()

void FUserWidgetPool::ReleaseAllSlateResources ( )

Reset of all cached underlying Slate widgets, but not the active UUserWidget objects

◆ ReleaseInactiveSlateResources()

void FUserWidgetPool::ReleaseInactiveSlateResources ( )

Reset of all cached underlying Slate widgets, only for inactive widgets in the pool.

◆ ReleaseSlateResources()

void FUserWidgetPool::ReleaseSlateResources ( )
inline

◆ ResetPool()

void FUserWidgetPool::ResetPool ( )

Full reset of all created widget objects (and any cached underlying slate)

◆ SetDefaultPlayerController()

void FUserWidgetPool::SetDefaultPlayerController ( APlayerController InDefaultPlayerController)

In the case a pool has no owner widget, a default player controller can optionally be specified allowing greater control
in split screen scenarios. The following priority rules are applied when determining the controller which should own created widgets: Controller of owning widget (if set) > Default player controller (if set) > First local player controller from world.

◆ SetWorld()

void FUserWidgetPool::SetWorld ( UWorld OwningWorld)

In the case that you don't have an owner widget, you should set a world to your pool, or it won't be able to construct widgets.


The documentation for this struct was generated from the following files: