Getting UObjects from file path and storing them into an array.

Hi,
I’m trying to get all UObjects from a folder into a TArray, what’s an efficient way of doing it? Having to input each UObject by hand into an array is a bit tedious. Any help is appreciated.

This might help you:


FName path;
TArray<UTexture2D*> result;
UObjectLibrary* lib = UObjectLibrary::CreateLibrary(UTexture2D::StaticClass(), false, true);

lib->LoadAssetDataFromPath(path.ToString());
TArray<FAssetData> assetData;
lib->GetAssetDataList(assetData);

for (FAssetData asset : assetData) {
result.Add(Cast<UTexture2D>(asset.GetAsset()));
}