Download

AssetRegistrySearchable: How do i use it properly?

Currently a bit puzzled on how to use AssetRegistrySearchable exactly. My goal is to extend UWorldSettings with new properties, so our LevelDesigners can set things like Title&Description, which we want to display ingame in the SelectMenu. I looked into the source for UnrealTournament(See links at the end of the post)

They add the UpropertyTag AssetRegistrySearchable, and i wondered, if its possible to get the new information through the AssetRegistry, without actually doing the manual steps they do. I thought these UProperties would be availaible as ETag/Value on Assets. So i searched all assets with AssetClass world(But in BP), but they had not Tag/Values as it seemed.

Can someone explain to me how AssetRegistrySearchable is supposed to work?
Othwhise if it does not help in my usecase, i’d simply go the same way they did.

https://github.com/EpicGames/UnrealT…ngine.cpp#L962
https://github.com/EpicGames/UnrealT…LevelSummary.h

hello from the future. you might have already found the solution. But i am leaving a reply here for people who are having trouble.

using assetregistrysearchable tag.

  1. mark the UPROPERTY with this tag.
//in UMyObject class
UPROPERTY(EditAnywhere, BlueprintReadOnly, AssetRegistrySerachable)
bool bLegendaryItem;
  1. Get FAssetData of the asset for example from AssetManager.
FAssetData AssetData;
UAssetManager::GetIfValid()->GetPrimaryAssetData(PrimaryAssetId,  AssetData);
  1. retrieve value of bLegendaryItem WITHOUT loading the whole asset.
bool bItemIsLegendary;

FName AssetRegistrySearchablePropertyName = GET_MEMBER_NAME_CHECKED(UMyObject, bLegendaryItem);

AssetData->AssetData.GetTagValue(AssetRegistrySearchablePropertyName, bItemIsLegendary);

if (bItemIsLegendary)
{
        GEngine->AddOnScreenDebugMessage(-1, 10.f, FColor::Blue, TEXT("Item is legendary");
        //Maybe you want to load the asset now?
}

For more complex AssetRegistrySearchable tags, E.g FGameplayTag GetTagValue() will not work. Instead, try this:

FAssetDataTagMapSharedView::FFindTagResult TagValue = AssetData.TagsAndValues.FindTag( GET_MEMBER_NAME_CHECKD(YourUObjectClass, PropertyName) );

if ( TagValue.IsSet() )
{
    /** Do your magic here.  */
}

FYI @sp3cim4n uses the Asset Manager, which utilizes the Asset Registry. Let me just say the Asset Manager is very useful for checking certain information in an asset before it’s loaded, which saves on memory. I myself have a derived Asset Manager that adds in a lot more functionality than the base Asset Manager class provides.

For instance, the Asset Manager has trouble with Widget Blueprints and their Primary Asset Types base class in packaged builds. This is because packaging strips away everything editor related and you are left with a UWigetBlueprintGeneratedClass, instead of a BaseClassSelectedInAssetManagerSettings. I have a work around that I posted on the forums Here.

1 Like