Asset Registry: Get all assets of specific class?

In my GameInstance class I’m trying to retrieve all assets of a specific class/struct so that I can have an asset registry for that class without having to duplicate code everywhere. To do that, I was planning on using this code:

// UPSTileAsset is a subclass of UDataAsset that contains tile relevant information (collision, material, texture, mesh)
FAssetRegistryModule& AssetRegistryModule = FModuleManager::LoadModuleChecked<FAssetRegistryModule>("AssetRegistry");
	TArray<FAssetData> AssetData;
	const UClass* Class = UPSTileAsset::StaticClass();
	AssetRegistryModule.Get().GetAssetsByClass(FName(*Class->GetName()), AssetData);
	for (FAssetData asset : AssetData) {
		UPSTileAsset* loadedAsset = (UPSTileAsset*)asset.GetAsset();
		m_Tiles.Add(loadedAsset->uniqueName, loadedAsset);
	}

However, the TArray is always empty. How can I fix this, if at all?

I managed to fix it. Turns out Assets in the registry don’t have U prefix, so Class->GetName() would not work properly.

Just replace Class->GetName() with the actual class name minus the U prefix.

How did you fix it then?