I’m trying to load text from a .txt file to a string, to use in my level blueprint. To test this, when pressing the q key some words from my text file should be printed ot the screen. However, nothing happens.
Any ideas where I’m going wrong? Here’s the code:
.CPP
#include "MuseumProject.h"
#include "MyBlueprintFunctionLibrary.h"
// Load and save text files
bool UMyBlueprintFunctionLibrary::FileSaveString(FString SaveTextB, FString FileNameB)
{
return FFileHelper::SaveStringToFile(SaveTextB, *(FPaths::GameDir() + FileNameB));
}
bool UMyBlueprintFunctionLibrary::FileLoadString(FString FileNameA, FString& SaveTextA)
{
return FFileHelper::LoadFileToString(SaveTextA, *(FPaths::GameDir() + FileNameA));
}
FString UMyBlueprintFunctionLibrary::FileLoadAndReturnString(FString FileNameA)
{
FString myString;
bool myBool = true;
myBool = FFileHelper::LoadFileToString(myString, *(FPaths::GameDir() + FileNameA));
return myString;
}
.H
#pragma once
#include "Kismet/BlueprintFunctionLibrary.h"
#include "MyBlueprintFunctionLibrary.generated.h"
UCLASS()
class MUSEUMPROJECT_API UMyBlueprintFunctionLibrary : public UBlueprintFunctionLibrary
{
GENERATED_BODY()
public:
UFUNCTION(BlueprintCallable, Category = "save")
static bool FileSaveString(FString SaveTextB, FString FileNameB);
UFUNCTION(BlueprintPure, Category = "save")
static bool FileLoadString(FString FileNameA, FString& SaveTextA);
UFUNCTION(BlueprintCallable, Category = "save")
static FString FileLoadAndReturnString(FString FileNameA);
};
The Blueprint
Coding is not my strong point so any help is appreciated.
Thank you! - SB7