I’m trying to get an array of assets by class type.
The thing is that I don’t get all the files that exist of the required class.
For example: I tried to get the USoundCue files
GetAssets<USoundCue>((TArray<USoundCue*>&)SoundBase);
But only one appeared on the list.
I know I have another SoundCue that is not listed.
In fact the missing Sound Cue is compiled immediately after printing the list (This is done by the engine, not me).
This is the missing Sound Cue.
This is my code:
template<class T>
void GetAssets(TArray<T*> &OutAsset)
{
FAssetRegistryModule& AssetRegistryModule = FModuleManager::LoadModuleChecked<FAssetRegistryModule>("AssetRegistry");
TArray<FAssetData> AssetData;
const UClass* Class = T::StaticClass();
if (!IsValid(Class)) return;
const FName InPackageName = *Class->GetPackage()->GetName();
const FName InAssetName = Class->GetFName();
AssetRegistryModule.Get().GetAssetsByClass(FTopLevelAssetPath(InPackageName, InAssetName), AssetData);
for (FAssetData& Item : AssetData)
{
T *AssetPtr = Cast<T>(Item.GetAsset());
if (!IsValid(AssetPtr)) continue;
OutAsset.Add(AssetPtr);
}
}
The question is more than obvious.
Why some files not appear in the registry?
What can i do to make the missing files appear in the registry?
Thank you so much!!