Hello guys,
im on my Bachelor thesis and created a demo which i like to monitor.
My question is: I’ve got a 2DVector Array/list with position datas and like to save them to a txt/csv/whatever file is possible. Im searching an easy way to store this variables externally.
Thanks for your help!
Kenji
in a blueprintFunctionLibrary, you can save a string in a txt file like this:
.h
#include "Engine.h"
...
UFUNCTION(BlueprintCallable, Category = "Save")
static bool FileSaveString(FString SaveTextB, FString FileNameB);
UFUNCTION(BlueprintPure, Category = "Save")
static bool FileLoadString(FString FileNameA, FString& SaveTextA);
.cpp
bool UOmniBlueprintFunctionLibrary::FileSaveString(FString SaveTextB, FString FileNameB)
{
return FFileHelper::SaveStringToFile(SaveTextB, *(FPaths::GameDir() + FileNameB));
}
bool UOmniBlueprintFunctionLibrary::FileLoadString(FString FileNameA, FString& SaveTextA)
{
return FFileHelper::LoadFileToString(SaveTextA, *(FPaths::GameDir() + FileNameA));
}
saving as a .csv is the same as a text file, you just separate the values by commas in a concatenated string, and save it with a .csv extension
I don’t think UE4 Blueprints let you write to text files out of the box, but there’s been a big plugin library written that adds support for it. You will have to convert your array of points to a string and look for SaveStringTextToFile
(39) 's Extra Blueprint Nodes for You as a Plugin, No C++ Required! - Blueprint - Epic Developer Community Forums !
Xanitsu
(Xanitsu)
September 14, 2016, 6:19pm
4
you could also use rama’s victory plugin it has that support for blueprints
this works fine on my side with 4.17.2 … many thanks man … : ) ,
Vorsering
(Vorsering)
February 8, 2019, 1:13pm
6
I resolved this problem today. You can add this in every class
.h
//Save Directory is where i want to save the file, FinalString is What I want to save
UFUNCTION(BlueprintCallable, Category = “custom”, meta = (Keywords = “Save”))
static bool SaveText(FString SaveDirectory,FString FinalString);
.cpp
bool ABaseActor::SaveText(FString SaveDirectory,FString FinalString)
{
UE_LOG(LogTemp, Warning, TEXT(“Salvato in: %s”), *SaveDirectory); //where i’m saving the file
UE_LOG(LogTemp, Warning, TEXT(“TestoSalvato: %s”), *FinalString); //what i’m saving
return FFileHelper::SaveStringToFile(FinalString, *SaveDirectory); //Saving
}