Asset Manager Name Data Accessibility

Hello! I have a question about the UAssetManager FPrimaryAssetData type. When implementing a custom subclass of UAssetManager, it seems that this function is available:

`protected:

/** Returns the NameData for a specific type/name pair /
ENGINE_API FPrimaryAssetData
GetNameData(const FPrimaryAssetId& PrimaryAssetId, bool bCheckRedirector = true);
ENGINE_API const FPrimaryAssetData* GetNameData(const FPrimaryAssetId& PrimaryAssetId, bool bCheckRedirector = true) const;`From ENGINE_API, it seems that this is meant to be used by/available to subclasses. However, the definition for this struct is in AssetManager.cpp, making it unusable by children. What’s the intended use here? Should this information be available to derived classes, or is there another way to work with this state data?

Hi,

There is no ways to directly use FPrimaryAssetData type outside AssetManager.cpp. I took a look at the history it has been like that since it’s creation. The ENGINE_API was added by a automated script where the exports were on the entire type (UAssetManager) previously and then was moved to method/functions. In the current implementation, the API should be private. It is hard to tell what was the intent when it was designed. But today, it can be an issue or not for you, depending what you need to do with this? You can indirectly access FPrimaryAssetData::GetAssetPtr() through the public UAssetManager::GetPrimaryAssetObject (see snippet below), but the two other public methods (FPrimaryAssetData::GetARLookupPath()/FPrimaryAssetData::IsLoaded) are not accessible, or at least, this is not as obvious. Do you need to override some of the underlying logic or directly use the API?

`struct FPrimaryAssetData
{

/** Path to this asset on disk /
const FSoftObjectPtr& GetAssetPtr() const { return AssetPtr; }
/
* Path used to look up cached asset data in the asset registry. This will be missing the _C for blueprint classes /
const FSoftObjectPath& GetARLookupPath() const { return ARLookupPath; }
/
* Asset is considered loaded at all if there is an active handle for it */
bool IsLoaded() const { return CurrentState.IsValid(); }

};

// PUBLIC
UObject* UAssetManager::GetPrimaryAssetObject(const FPrimaryAssetId& PrimaryAssetId) const
{
const FPrimaryAssetData* NameData = GetNameData(PrimaryAssetId);

if (NameData)
{
return NameData->GetAssetPtr().Get();
}

return nullptr;
}`Regards,

Patrick