Hello everyone,
I’m currently trying to create a blueprint node for the population of an Array of Static Meshes from the .uassets contained in a given folder of the project.
I created an object inheriting from UBlueprintFunctionLibrary and declared the static method:
static bool GetMeshesInFolder(UPARAM(ref) TArray<UStaticMesh*>& MeshesArray, FString InternalPath, FString Ext="*.uasset");
Here is what I’m currently doing in the definition:
bool UImportMeshArray::GetMeshesInFolder(UPARAM(ref) TArray<UStaticMesh*>& MeshesArray, FString InternalPath, FString Ext)
{
if (InternalPath.Len() < 1) return false;
FString GameContentDir = FPaths::GameContentDir();
FPaths::NormalizeDirectoryName(InternalPath);
FString FullPath = FPaths::Combine(GameContentDir, InternalPath);
IFileManager& FileManager = IFileManager::Get();
if (Ext == "")
{
Ext = ".";
}
else
{
Ext = (Ext.Left(1) == ".") ? "" + Ext : "*." + Ext;
}
FString FinalPath = FullPath + "/" + Ext;
TArray<FString> Files = TArray<FString>();
FileManager.FindFiles(Files, *FinalPath, true, false);
FString FilePath;
MeshesArray = TArray<UStaticMesh*>();
for (FString FileName : Files)
{
FilePath = InternalPath + "/" + FileName;
UE_LOG(LogTemp, Warning, TEXT("%s"), *FilePath);
static ConstructorHelpers::FObjectFinder<UStaticMesh> CurrentMesh(*FilePath);
UStaticMesh* Asset = MeshAsset.Object;
GhostMesh->SetStaticMesh(Asset);*/
if (CurrentMesh.Succeeded())
{
MeshesArray.Add(CurrentMesh.Object);
}
}
return true;
}
When I try to run this function from the python console or when i connect it into the blueprint component I’ designed it for, the editor is crashing.
Can you please help me?
Thanks