I have tried to follow the instruction to load the list of String into TArray.
The HiddenWordList.txt is stored under WordLists in Content File.
And I also add the WordLists directory to the list of Additional Non-Asset Directories
When I try to print the loaded list but found the size is empty. (seems it fails to load the file into the array)
I also found that the path was a relative path instead of absolute path, not sure if it is related.
But I also tried to replace it with absolute path but still can’t fix the issue
#include "BullCowCartridge.h"
#include "HiddenWordList.h"
#include "Misc/FileHelper.h"
#include "Misc/Paths.h"
void UBullCowCartridge::BeginPlay() // When the game starts
{
Super::BeginPlay();
const FString WordListPath = FPaths::ProjectContentDir() / TEXT("WordLists/HiddenWordList.txt");
bool bSuccess = FFileHelper::LoadFileToStringArray(FileWordList, *WordListPath);
PrintLine(TEXT("Path : %s"), *WordListPath);
PrintLine(TEXT("FileWordList size : %i"), FileWordList.Num());
if (bSuccess)
{
PrintLine(TEXT("Load success : True"));
}
else
{
PrintLine(TEXT("Load success : False"));
}
// SetupGame();
// PrintLine(TEXT("The Hidden word is: %s."), *HiddenWord);
}