๐ฆ Asset Registration System
Short Description
Gorgeous Things includes an asset registration system that allows you to easily register custom asset types and categories in the Unreal Editor's content browser. This system provides macros and helper functions to streamline the registration process, including support for custom icons, thumbnails, type colors, and sub-menu categorization.
Long Description
The asset registration system in Gorgeous Things is designed to simplify the process of registering custom asset types in the Unreal Editor. By using a set of macros and underlying helper functions in the GorgeousAssetRegistration namespace, you can register asset categories, define asset type actions with full metadata (display name, supported class, type color, icon, thumbnail, sub-menus), and cleanly unregister everything on module shutdown.
The main macro, GORGEOUS_REGISTER_ASSET_CATEGORY, allows you to create a shared asset category under which all your custom asset types will be grouped in the content browser. The REGISTER_GORGEOUS_ASSET macro handles the actual registration of asset type actions, while GORGEOUS_MAKE_INFO and GORGEOUS_MAKE_INFO_WITH_BRUSHES construct the metadata structure needed for registration โ either by looking up brushes from a style set or by providing them directly.
For cleanup, UNREGISTER_GORGEOUS_ASSET and UNREGISTER_GORGEOUS_ASSETS ensure that all registered asset type actions are properly unregistered when your module shuts down. This system promotes consistency and reduces boilerplate, letting you focus on defining your assets rather than wiring up registration logic.
Factory
To fully utilize a registered asset type, you will typically also need to implement a corresponding UGorgeousFactory subclass that defines how new assets of that type are created. This factory class should be implemented in the same module and registered with the Unreal Editor, often in conjunction with the asset type registration process. The factory will handle the logic for creating new instances of your custom asset type when users select it from the "Add" menu in the content browser.
UCLASS()
class UGorgeousObjectVariableFactory : public UGorgeousFactory
{
GENERATED_BODY()
public:
UGorgeousObjectVariableFactory()
{
SetFactoryInformation(FGorgeousFactoryInfo_S(UGorgeousObjectVariable::StaticClass(), true, false, true, false,
UGorgeousObjectVariableBlueprint::StaticClass()));
}
};
More more examples look at Source/GorgeousCoreEditor/Private/HeaderFiles/Factories/
๐ Features (Macro Side)
GORGEOUS_REGISTER_ASSET_CATEGORY
Registers a new asset category in the Unreal Editor, which will be used to group all custom asset types related to Gorgeous Things under a common category in the content browser. It loads the AssetTools module and calls RegisterAdvancedAssetCategory, storing the resulting category type in GorgeousAssetRegistration::GGorgeousThingsCategory for later use when registering individual asset types.
| Parameter | Type | Description |
|---|---|---|
CategoryName |
FString |
The name of the asset category to register, used as the internal identifier for the category. |
LocalizedDisplayName |
FString |
The localized display name of the asset category, which will be shown to the user in the content browser's category filter. |
// In your module's StartupModule function
// Register a custom asset category for Gorgeous Things
GORGEOUS_REGISTER_ASSET_CATEGORY("GorgeousThings", "Gorgeous Things");
REGISTER_GORGEOUS_ASSET
Registers a custom asset type in the Unreal Editor, using the provided metadata structure. It creates a new FGorgeousAssetTypeAction instance from the given FGorgeousAssetTypeActionInfo_S structure, registers it with the AssetTools module, and adds it to the GorgeousAssetRegistration::GRegisteredAssetTypeActions array so it can be properly unregistered later during module shutdown.
| Parameter | Type | Description |
|---|---|---|
AssetTypeInfo |
FGorgeousAssetTypeActionInfo_S |
A structure containing metadata about the asset type, such as its display name, supported class, type color, and icon information. Typically constructed using GORGEOUS_MAKE_INFO or GORGEOUS_MAKE_INFO_WITH_BRUSHES. |
// In your module's StartupModule function
const FText CoreMenu = NSLOCTEXT("GorgeousCore", "Menu_GorgeousCore", "Gorgeous Core");
// Register a custom asset type using GORGEOUS_MAKE_INFO (icon from style set)
REGISTER_GORGEOUS_ASSET(GORGEOUS_MAKE_INFO(
NSLOCTEXT("GorgeousCore", "ObjectVariable", "Gorgeous Object Variable"),
UGorgeousObjectVariableBlueprint::StaticClass(),
FColor::Blue,
TEXT("ObjectVariable"),
CoreMenu));
// Register a custom asset type using GORGEOUS_MAKE_INFO_WITH_BRUSHES (direct brushes)
REGISTER_GORGEOUS_ASSET(GORGEOUS_MAKE_INFO_WITH_BRUSHES(
NSLOCTEXT("GorgeousCore", "GameMode", "Gorgeous Game Mode"),
UGorgeousGameModeBlueprint::StaticClass(),
FColor::Blue,
FAppStyle::Get().GetBrush(TEXT("ClassIcon.GameModeBase")),
FAppStyle::Get().GetBrush(TEXT("ClassThumbnail.GameModeBase")),
CoreMenu));
GORGEOUS_MAKE_INFO
Creates a metadata structure (FGorgeousAssetTypeActionInfo_S) for a custom asset type, which can be used to register the asset type in the Unreal Editor. It delegates to the GorgeousAssetRegistration::MakeInfo helper function, automatically passing the registered GGorgeousThingsCategory and the GGorgeousStyleSet from GorgeousStyleRegistration. The icon and thumbnail brushes are looked up from the style set using the provided IconKey.
| Parameter | Type | Description |
|---|---|---|
DisplayName |
FText |
The localized display name of the asset type, shown in the content browser and asset creation menus. |
SupportedClass |
UClass* |
The UClass that this asset type supports, typically obtained via StaticClass(). |
TypeColor |
FColor |
The color used to visually represent this asset type in the content browser (e.g., node pin color). |
IconKey |
FName |
The key used to look up the icon for this asset type in the style set. The function will look for both "GorgeousCore.{IconKey}.Icon" and "GorgeousCore.{IconKey}.Thumbnail" brushes. Pass NAME_None to skip icon lookup. |
... |
FText |
Variadic sub-category names that this asset type belongs to, which define the nested sub-menu structure in the content browser's "Add" menu. |
// Within your module's StartupModule function
const FText CoreMenu = NSLOCTEXT("GorgeousCore", "Menu_GorgeousCore", "Gorgeous Core");
const FText Menu_ConditionalChoosers = NSLOCTEXT("GorgeousCore", "Menu_ConditionalChoosers", "Conditional Object Choosers");
const FText Menu_Conditions = NSLOCTEXT("GorgeousCore", "Menu_Conditions", "Conditions");
// Simple registration with a single sub-menu
REGISTER_GORGEOUS_ASSET(GORGEOUS_MAKE_INFO(
NSLOCTEXT("GorgeousCore", "ObjectVariable", "Gorgeous Object Variable"),
UGorgeousObjectVariableBlueprint::StaticClass(),
FColor::Blue,
TEXT("ObjectVariable"),
CoreMenu));
// Registration with nested sub-menus
REGISTER_GORGEOUS_ASSET(GORGEOUS_MAKE_INFO(
NSLOCTEXT("GorgeousCore", "Condition", "Gorgeous Condition"),
UGorgeousConditionBlueprint::StaticClass(),
FColor::Turquoise,
TEXT("Condition"),
CoreMenu, Menu_ConditionalChoosers, Menu_Conditions));
// Registration without a custom icon (NAME_None)
REGISTER_GORGEOUS_ASSET(GORGEOUS_MAKE_INFO(
NSLOCTEXT("GorgeousCore", "GameInstance", "Gorgeous Game Instance"),
UGorgeousGameInstanceBlueprint::StaticClass(),
FColor::Blue,
NAME_None,
CoreMenu));
GORGEOUS_MAKE_INFO_WITH_BRUSHES
Creates a metadata structure (FGorgeousAssetTypeActionInfo_S) for a custom asset type, with directly provided icon and thumbnail brushes instead of looking them up from a style set. It delegates to the GorgeousAssetRegistration::MakeInfoWithBrushes helper function, automatically passing the registered GGorgeousThingsCategory. This is useful when you want to use engine-provided brushes (via FAppStyle) or brushes from a custom style set.
| Parameter | Type | Description |
|---|---|---|
DisplayName |
FText |
The localized display name of the asset type, shown in the content browser and asset creation menus. |
SupportedClass |
UClass* |
The UClass that this asset type supports, typically obtained via StaticClass(). |
TypeColor |
FColor |
The color used to visually represent this asset type in the content browser (e.g., node pin color). |
IconBrush |
const FSlateBrush* |
The FSlateBrush used as the icon for this asset type in the content browser. |
ThumbnailBrush |
const FSlateBrush* |
The FSlateBrush used as the thumbnail for this asset type in the content browser. |
... |
FText |
Variadic sub-category names that this asset type belongs to, which define the nested sub-menu structure in the content browser's "Add" menu. |
// Within your module's StartupModule function
const FText CoreMenu = NSLOCTEXT("GorgeousCore", "Menu_GorgeousCore", "Gorgeous Core");
const FText Menu_QualityOfLife = NSLOCTEXT("GorgeousCore", "Menu_QualityOfLife", "Quality of Life");
// Using engine-provided brushes from FAppStyle
REGISTER_GORGEOUS_ASSET(GORGEOUS_MAKE_INFO_WITH_BRUSHES(
NSLOCTEXT("GorgeousCore", "GameMode", "Gorgeous Game Mode"),
UGorgeousGameModeBlueprint::StaticClass(),
FColor::Blue,
FAppStyle::Get().GetBrush(TEXT("ClassIcon.GameModeBase")),
FAppStyle::Get().GetBrush(TEXT("ClassThumbnail.GameModeBase")),
CoreMenu, Menu_QualityOfLife));
// Using brushes from a custom module style set
REGISTER_GORGEOUS_ASSET(GORGEOUS_MAKE_INFO_WITH_BRUSHES(
NSLOCTEXT("GorgeousCore", "PlayerState", "Gorgeous Player State"),
UGorgeousPlayerStateBlueprint::StaticClass(),
FColor::Blue,
ModuleStyleSet->GetBrush(TEXT("ClassIcon.GorgeousPlayerStateBlueprint")),
ModuleStyleSet->GetBrush(TEXT("ClassThumbnail.GorgeousPlayerStateBlueprint")),
CoreMenu, Menu_QualityOfLife));
UNREGISTER_GORGEOUS_ASSET
Unregisters a previously registered custom asset type from the Unreal Editor. It calls UnregisterAssetTypeActions on the AssetTools module and removes the action from the GorgeousAssetRegistration::GRegisteredAssetTypeActions array. This macro is primarily used internally by UNREGISTER_GORGEOUS_ASSETS but can also be called directly if you need to unregister a specific asset type action.
| Parameter | Type | Description |
|---|---|---|
AssetTypeAction |
TSharedRef<IAssetTypeActions> |
The shared reference to the IAssetTypeActions instance that was used to register the asset type, which will be unregistered and removed from the list of registered asset type actions. |
// Unregister a specific asset type action
UNREGISTER_GORGEOUS_ASSET(MyAssetTypeAction);
UNREGISTER_GORGEOUS_ASSETS
Unregisters all previously registered custom asset types from the Unreal Editor. It iterates through the GorgeousAssetRegistration::GRegisteredAssetTypeActions array, unregistering each valid action using UNREGISTER_GORGEOUS_ASSET, and then clears the list. It includes a safety check to verify that the AssetTools module is still loaded before attempting to unregister, resetting the array instead if the module has already been unloaded.
This macro takes no parameters.
// In your module's ShutdownModule function
void FMyPluginModule::ShutdownModule()
{
// Unregister all previously registered asset types
UNREGISTER_GORGEOUS_ASSETS;
}
๐ Features (Namespace Side)
Helper Functions
The GorgeousAssetRegistration namespace contains underlying forceinline helper functions that are called by the macros to perform the actual work of constructing asset type metadata structures. These functions take in the necessary parameters to populate FGorgeousAssetTypeActionInfo_S instances, allowing the macros to provide a clean and simple interface for registering asset types while keeping the implementation details encapsulated within these helper functions. The namespace also holds shared state variables for the registered asset category and the list of registered asset type actions.
MakeInfo
Creates a metadata structure (FGorgeousAssetTypeActionInfo_S) for a custom asset type, which can be used to register the asset type in the Unreal Editor. It populates the structure with the provided display name, supported class, type color, asset category, and sub-menus. It also retrieves the icon and thumbnail brushes from the provided style set using the IconKey, looking up brushes named "GorgeousCore.{IconKey}.Icon" and "GorgeousCore.{IconKey}.Thumbnail". If the style set is invalid or the icon key is NAME_None, the brushes are set to nullptr.
| Parameter | Type | Description |
|---|---|---|
AssetCategories |
EAssetTypeCategories::Type |
The asset category or categories that this asset type belongs to, used for organizational purposes in the content browser. |
Style |
TSharedPtr<FSlateStyleSet>& |
The style set from which to retrieve the icon and thumbnail brushes for this asset type. |
DisplayName |
FText |
The localized display name of the asset type. |
SupportedClass |
UClass* |
The UClass that this asset type supports. |
TypeColor |
FColor |
The color used to visually represent this asset type in the content browser. |
SubMenus |
TArray<FText> |
Sub-category names that this asset type belongs to, which can be used for organizational purposes in the content browser. |
IconKey |
FName |
The key used to look up the icon for this asset type in the style set. The function will look for both "GorgeousCore.{IconKey}.Icon" and "GorgeousCore.{IconKey}.Thumbnail" brushes in the style set. |
| Type | Description |
|---|---|
FGorgeousAssetTypeActionInfo_S |
A populated metadata structure with the provided information and retrieved brushes. |
// Example of using the MakeInfo helper function directly (though typically you would use the GORGEOUS_MAKE_INFO macro)
FGorgeousAssetTypeActionInfo_S Info = GorgeousAssetRegistration::MakeInfo(
GorgeousAssetRegistration::GGorgeousThingsCategory,
GorgeousStyleRegistration::GGorgeousStyleSet,
NSLOCTEXT("GorgeousCore", "ObjectVariable", "Gorgeous Object Variable"),
UGorgeousObjectVariableBlueprint::StaticClass(),
FColor::Blue,
{ NSLOCTEXT("GorgeousCore", "Menu_GorgeousCore", "Gorgeous Core") },
TEXT("ObjectVariable"));
MakeInfoWithBrushes
Creates a metadata structure (FGorgeousAssetTypeActionInfo_S) for a custom asset type, with directly provided icon and thumbnail brushes instead of looking them up from a style set. It populates the structure with the provided display name, supported class, type color, asset category, sub-menus, and the given brush pointers. This is useful when you want to use engine-provided brushes or brushes from a different source than the default Gorgeous style set.
| Parameter | Type | Description |
|---|---|---|
AssetCategories |
EAssetTypeCategories::Type |
The asset category or categories that this asset type belongs to, used for organizational purposes in the content browser. |
DisplayName |
FText |
The localized display name of the asset type. |
SupportedClass |
UClass* |
The UClass that this asset type supports. |
TypeColor |
FColor |
The color used to visually represent this asset type in the content browser. |
SubMenus |
TArray<FText> |
Sub-category names that this asset type belongs to, which can be used for organizational purposes in the content browser. |
IconBrush |
const FSlateBrush* |
The FSlateBrush used as the icon for this asset type in the content browser. |
ThumbnailBrush |
const FSlateBrush* |
The FSlateBrush used as the thumbnail for this asset type in the content browser. |
| Type | Description |
|---|---|
FGorgeousAssetTypeActionInfo_S |
A populated metadata structure with the provided information and brushes. |
// Example of using the MakeInfoWithBrushes helper function directly (though typically you would use the GORGEOUS_MAKE_INFO_WITH_BRUSHES macro)
FGorgeousAssetTypeActionInfo_S Info = GorgeousAssetRegistration::MakeInfoWithBrushes(
GorgeousAssetRegistration::GGorgeousThingsCategory,
NSLOCTEXT("GorgeousCore", "GameMode", "Gorgeous Game Mode"),
UGorgeousGameModeBlueprint::StaticClass(),
FColor::Blue,
{ NSLOCTEXT("GorgeousCore", "Menu_GorgeousCore", "Gorgeous Core"), NSLOCTEXT("GorgeousCore", "Menu_QualityOfLife", "Quality of Life") },
FAppStyle::Get().GetBrush(TEXT("ClassIcon.GameModeBase")),
FAppStyle::Get().GetBrush(TEXT("ClassThumbnail.GameModeBase")));
Likely Outdated
As for newer Unreal versions, the asset registration got simplified by UAssetDefinitionDefault base classes, but for backwards compatibility and more complex asset types the system is still in place and used for all asset registrations in Gorgeous Things. The macros and helper functions provide a consistent way to register assets across different Unreal Engine versions, while also allowing for more advanced customization when needed.