Building Subsystem¶
UBuildingSubsystem is a UGameInstanceSubsystem responsible for loading, caching, and querying the project's Building Data Asset assets.
It shares the same lifetime as the GameInstance and can persist across level transitions. Building Entities, Chunks, and runtime representations in the current world are managed by UBuildingWorldSubsystem.
Getting the Subsystem¶
Blueprint¶
C++¶
UBuildingSubsystem* BuildingSubsystem =
GetGameInstance()->GetSubsystem<UBuildingSubsystem>();
if (!IsValid(BuildingSubsystem))
{
return;
}
Building Asset Queries¶
| API | Description |
|---|---|
GetAllBuildings |
Returns all loaded building assets. |
GetBuildingsByCategory |
Returns building assets belonging to a specified category. |
GetBuildingDataByAssetId |
Returns a building asset by Primary Asset ID. |
GetAllBuildings¶
Returns all loaded building data assets.
GetBuildingsByCategory¶
Returns the building data assets that belong to the specified Category.
The category value comes from UBuildingDataAsset::Category.
GetBuildingDataByAssetId¶
Returns the loaded building asset associated with the specified Primary Asset ID. Returns nullptr if no matching asset is found.
This API is commonly used during building creation, network synchronization, and save restoration.
Loading State¶
| API | Return Type | Description |
|---|---|---|
AreBuildingAssetsLoaded |
bool |
Whether all building assets have finished loading. |
GetLoadProgress |
float |
The loading progress, from 0.0 to 1.0. |
GetLoadedBuildingCount |
int32 |
The number of building assets currently loaded. |
GetTotalBuildingCount |
int32 |
The total number of building assets found during the current scan. |
If no building assets are found, the loading state should immediately be treated as complete:
Loading Events¶
| Event | Description |
|---|---|
OnBuildingAssetLoadProgressChanged |
Triggered when the loading progress or asset counts change. |
OnBuildingAssetLoaded |
Triggered when an individual building asset becomes available. |
OnBuildingAssetsLoaded |
Triggered when all building assets have finished loading. |
OnBuildingAssetLoadingCanceled |
Triggered when the current asynchronous loading request is canceled. |
OnBuildingAssetLoadProgressChanged¶
Parameters:
| Parameter | Type | Description |
|---|---|---|
Progress |
float |
The current loading progress. |
LoadedCount |
int32 |
The number of assets currently loaded. |
TotalCount |
int32 |
The total number of assets in the current load operation. |
This event can be used to update a loading progress bar.
OnBuildingAssetLoaded¶
Parameters:
| Parameter | Type | Description |
|---|---|---|
BuildingData |
UBuildingDataAsset* |
The building asset that has become available. |
LoadedCount |
int32 |
The number of assets currently loaded. |
OnBuildingAssetsLoaded¶
Triggered after all building assets have finished loading.
After receiving this event, call GetAllBuildings() to refresh the building menu.
Usage Workflow¶
If loading is complete:
If loading is still in progress:
Bind the loading progress event
→ Update the loading interface
Bind the loading completed event
→ Get All Buildings
→ Refresh the building menu
Cost Checking Toggle¶
UBuildingSubsystem provides a runtime toggle for building cost validation.
Default state:
GetEnableCheckCost¶
Returns whether building cost validation is currently enabled.
SetEnableCheckCost¶
Enables or disables building cost validation.
This value is valid only for the current GameInstance lifetime. It is not automatically written to project settings or save data.
For the complete cost workflow, see Building Cost System.
Asset Sorting¶
After building assets finish loading, they are sorted by SortIndex in ascending order:
Subsystem Responsibilities¶
| Subsystem | Lifetime | Responsibility |
|---|---|---|
UBuildingSubsystem |
GameInstance |
Building asset loading, caching, and queries. |
UBuildingWorldSubsystem |
World |
Building Entities, Chunks, save data, and runtime representations. |
Do not store the following in UBuildingSubsystem:
- Actors from the current world
- Render Chunk Actors
- HISM Components
- HISM Instance Indexes
- Runtime Building Entity data
For world-level building management, see Building World Subsystem.
Troubleshooting¶
| Issue | What to Check |
|---|---|
| The building list is empty | Check whether building asset loading has completed. |
TotalCount is 0 |
Check the Asset Manager scan configuration. |
| Category queries return no results | Check the Category configured in the building assets. |
| Asset ID lookup fails | Check the Asset ID and loading state. |
| The UI does not refresh | Check whether the loading completed event is bound. |
| No buildings are available in a packaged build | Check the Primary Asset scan and packaging rules. |
For building asset configuration, see Building Data Assets.