FUserWidgetPool

Pools [UUserWidget](API\Runtime\UMG\Blueprint\UUserWidget) instances to minimize [UObject](API\Runtime\CoreUObject\UObject\UObject) and [SWidget](API\Runtime\SlateCore\Widgets\SWidget) allocations for UMG elements with dynamic entries.

Choose your operating system:

Windows

macOS

Linux

References

Module

UMG

Header

/Engine/Source/Runtime/UMG/Public/Blueprint/UserWidgetPool.h

Include

#include "Blueprint/UserWidgetPool.h"

Syntax

struct FUserWidgetPool

Remarks

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

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

Constructors

Name Description

Public function

FUserWidgetPool()

Public function

FUserWidgetPool

(
    UWidget& InOwningWidget
)

Destructors

Name Description

Public function

~FUserWidgetPool()

Functions

Name Description

Public function

void

 

AddReferencedObjects

(
    FReferenceCollector& Collector
)

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

Public function Const

const TArray...

 

GetActiveWidgets()

Public function

UserWidgetT ...

 

GetOrCreateInstance

(
    TSubclassOf< UserWidgetT > WidgetCl...,
    WidgetConstructFunc ConstructWidget...
)

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

Public function

UserWidgetT ...

 

GetOrCreateInstance

(
    TSubclassOf< UserWidgetT > WidgetCl...
)

Gets an instance of a widget of the given class.

Public function Const

bool

 

IsInitialized()

Public function

void

 

RebuildWidgets()

Triggers RebuildWidget on all currently active UserWidget instances

Public function

void

 

Release

(
    TArray< UUserWidget* > Widgets,
    bool bReleaseSlate
)

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

Public function

void

 

Release

(
    UUserWidget* Widget,
    bool bReleaseSlate
)

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

Public function

void

 

ReleaseAll

(
    bool bReleaseSlate
)

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

Public function

void

 

ReleaseAllSlateResources()

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

Public function

void

 

ReleaseInactiveSlateResources()

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

Public function

void

 

ResetPool()

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

Public function

void

 

SetDefaultPlayerController

(
    APlayerController* InDefaultPl...
)

In the case a pool has no owner widget, a default player controller can optionally be specified allowing greater control in split screen scenarios.

Public function

void

 

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.

Typedefs

Name

Description

WidgetConstructFunc

Deprecated Functions

Name Description

Public function

void

 

ReleaseSlateResources()

Use ReleaseAllSlateResources instead.

See Also