Download

BP node to get array of materials from folder

I am new to programming in unreal and I was trying to make a project to change materials from a variety of meshs through widget interface, and to do that i wanted to create an array with all the materials in the project, but i couldn’t do it with blueprints alone(adding each materials manually to an array would be to much work). So i tried to create the array through a c++ bp function library and found that an UObjectLibrary could load assets through the LoadAssetDataFromPath function and used:

auto ObjectLibrary = UObjectLibrary::CreateLibrary(UWorld::StaticClass(), false, true);
ObjectLibrary->LoadAssetDataFromPath(TEXT("/Game/Materials/Material_01.Material_01"));
TArray<FAssetData> AssetsData;
ObjectLibrary->GetAssetDataList(AssetsData);
int a = ObjectLibrary->GetAssetDataCount();
UE_LOG(LogTemp, Warning, TEXT(“DataCount,%d OR %d”), a , AssetsData.Num());

I tried using the “_C” suffix attached to my path as well as the "Material ‘/Game/Materials/Material_01.Material_01’ " copied reference path that unreal gives me (unreal interrupts the program with this alternative) and also using an instanced material, but my AssetsData array was still empty after that.
I tried using LoadObject function but also to no avail.
Is there any other way to get the materials i need in c++ so i can add them to an array?