I’m trying to accomplish something that I thought would be fairly simple, but, I cannot figure out how to do it. So, I’ve got a folder full of MediaTextures and I want to populate a list at runtime of those MediaTextures. I don’t want to use a Data Asset because that’s a bit inconvenient, every time another MediaTexture is added, it would have to manually be added to the data asset/cvs/excel. So, here’s one sort of thing that I’ve tried:
I’ve also tried using LoadObject(…) and StaticLoadObject(…) I’ve played around with using the full path to the directory (which I don’t think would even work in a packaged project) and I’ve tried using the paths that work in some other situations: “/Game/Movies” And, I simply cannot load these objects. I’ve spent too much time on this, what is the proper way to accomplish this?
Well, when choosing tags, asset registry gave me a hint. Here’s a nasty bruteforce solution: (In case anyone needs it or would like to give me some feedback)
FAssetRegistryModule& AssetRegistryModule = FModuleManager::LoadModuleChecked<FAssetRegistryModule>("AssetRegistry");
TArray<FAssetData> AssetData;
AssetRegistryModule.Get().GetAssetsByClass(FName("MediaTexture"), AssetData);
for (int i = 0; i < AssetData.Num(); i++) {
UMediaTexture* FoundMedia = Cast<UMediaTexture>(AssetData[i].GetAsset());
if (FoundMedia != NULL) {
FileNames.Add(AssetData[i].GetFullName());
Textures.Add(FoundMedia);
}
}
}