UGantryUIExtensionSubsystem
Named places in your game's UI that other content can fill, without the UI knowing what will arrive: a game mode adds its scoreboard to the HUD, a DLC pack adds a button to the main menu.
- A slot is a place in the UI, named by any gameplay tag your game chooses, such as
MyGame.UI.HUD.TopRight. The widget that owns that part of the UI registers the slot. - An entry is what goes in a slot: a class (usually a widget class) or an object (data for a widget the slot makes), with a priority. Content that extends the UI adds entries.
- A context says who an entry is for, such as a local player. A slot sees only entries with the same context, so each split-screen player's HUD sees its own. A slot with no context sees only entries with no context.
Gantry keeps the records and draws nothing. It creates no widgets and assumes no layers or input: the slot's owner decides what each entry becomes.
In Blueprint
To own a slot, for example in a HUD widget's Construct event:
- Call Register UI Extension Slot. Set Slot Tag, and set Context to Get Owning Local Player for a per-player HUD, or leave it empty for shared UI.
- Connect a custom event to Event. It fires with Added for every matching entry already in the slot, highest priority first, and then for every entry that arrives later. It fires with Removed when an entry leaves.
- On Added, create a widget from the entry's Content Class and add it to a panel. On Removed, remove the widget you made for that entry, matched by its Id.
- In Destruct, call Unregister UI Extension Slot with the handle.
To fill a slot from content with no code, add the Add UI Extensions stage to an experience: its entries are added while the experience is active, one per local player by default. To fill a slot from a Blueprint, call Add UI Extension (Class) or Add UI Extension (Object), keep the handle, and call Remove UI Extension when the content should leave.
In C++
The HUD widget registers its slot for its own player:
SlotHandle = ->;
The game mode's code puts its scoreboard in that slot for the same player:
EntryHandle = ->;
Call Unregister on either handle to remove the slot or the entry.
There is one registry per world, so slots and entries do not survive a map change. A slot with Match set to Partial also sees entries put under its tag, such as MyGame.UI.HUD.TopRight.Score.
- Inherits
UWorldSubsystem
Properties
| Property | Type | Default | Description |
|---|---|---|---|
Entries | TArray<FGantryUIExtensionEntry> |
Functions
AddEntryClass
Puts a class in a slot, usually a widget class for the slot's owner to create.
| Pin | Type | Direction | Description |
|---|---|---|---|
SlotTag | FGameplayTag | in | The slot. |
ContentClass | TSubclassOf<UObject> | in | The class. Nothing is added when it is empty. |
Priority = 0 | int32 | in | Order within the slot: higher comes first. |
Context = None | UObject* | in | Who it is for; only slots with the same context see it. |
| Return Value | FGantryUIExtensionEntryHandle | out | A handle to remove the entry with. |
AddEntryObject
Puts an object in a slot, usually data for a widget the slot's owner creates.
| Pin | Type | Direction | Description |
|---|---|---|---|
SlotTag | FGameplayTag | in | The slot. |
ContentObject | UObject* | in | The object. Nothing is added when it is empty. |
Priority = 0 | int32 | in | Order within the slot: higher comes first. |
Context = None | UObject* | in | Who it is for; only slots with the same context see it. |
| Return Value | FGantryUIExtensionEntryHandle | out | A handle to remove the entry with. |
GetEntries
The entries a slot with this tag, context and match would see now.
| Pin | Type | Direction | Description |
|---|---|---|---|
SlotTag | FGameplayTag | in | The slot. |
Context | UObject* | in | The slot's context. |
Match | EGantryTagMatch | in | Exact, or entries put under the slot's tag too. |
| Return Value | TArray<FGantryUIExtensionEntry> | out | The entries, highest priority first. |
K2_RegisterSlot
Registers a slot: Event fires at once for the matching entries already present, highest priority first, then for every arrival and departure.
| Pin | Type | Direction | Description |
|---|---|---|---|
SlotTag | FGameplayTag | in | The slot, any gameplay tag. |
Context | UObject* | in | Only entries with this same context are seen; empty for entries with none. |
Match | EGantryTagMatch | in | Exact, or entries put under the slot's tag too. |
Event | FGantryUIExtensionSlotEvent | in | Called with each entry and whether it arrived or left. |
| Return Value | FGantryUIExtensionSlotHandle | out | A handle to remove the slot with. |
RemoveEntry
Removes an entry; slots that saw it hear it leave.
| Pin | Type | Direction | Description |
|---|---|---|---|
Handle | FGantryUIExtensionEntryHandle | out | The handle Add UI Extension gave. |
UnregisterSlot
Removes a slot, so its Event fires no more.
| Pin | Type | Direction | Description |
|---|---|---|---|
Handle | FGantryUIExtensionSlotHandle | out | The handle Register UI Extension Slot gave. |
C++
Public C++ members that Blueprint does not see.
FSlotCallback
using UGantryUIExtensionSubsystem::FSlotCallback = TFunction<void>
The C++ slot callback: told when an entry arrives in the slot or leaves it.
Get
static UGantryUIExtensionSubsystem *
The subsystem of a world context's world.
WorldContextObject:Anything in a world.
Returns: The subsystem, or null outside a world.
DoesSupportWorldType
virtual bool
Created for game, Play In Editor and editor worlds.
RegisterSlot
FGantryUIExtensionSlotHandle
Registers a slot from C++.
The callback hears the matching entries already present at once, highest priority first, then every arrival and departure. Returns an empty handle when the tag is empty or the callback is unset.
RemoveEntryById
void
Removes an entry by id.
FGantryUIExtensionEntryHandle::Unregister calls this.
RemoveSlotById
void
Removes a slot by id.
FGantryUIExtensionSlotHandle::Unregister calls this.