TransporterFunctions
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "Kismet/BlueprintFunctionLibrary.h"
#include "TransporterFunctions.generated.h"
UCLASS()
class FEB9FINAL_API UTransporterFunctions : public UBlueprintFunctionLibrary
{
GENERATED_BODY()
};
#pragma once acts as the guards.
UCLASS() I believe is a macro (see here) which allows the code to "examine" it's self.
// Fill out your copyright notice in the Description page of Project Settings.
#include "TransporterFunctions.h"
class FEB9FINAL_API UTransporterFunctions : public UBlueprintFunctionLibrary
{
GENERATED_BODY()
UFUNCTION(BlueprintCallable, Category = "TransporterFuns")
static FString HelloWorld(int count);
FString UTransporterFunctions::HelloWorld(int count)
{
FString rv;
int i;
for (i = 0; i < count; i++) {
rv += TEXT("Hello World\n");
}
return rv;
}
UCLASS()
class FEB9FINAL_API UTransporterFunctions : public UBlueprintFunctionLibrary
{
GENERATED_BODY()
UFUNCTION(BlueprintCallable, Category = "TransporterFuns")
static FString HelloWorld(int count);
UFUNCTION(BlueprintCallable, Category = "TransporterFuns")
static TArray<FString> ReadPlaceFile(FString filename, bool& success);
};
TArray<FString> UTransporterFunctions::ReadPlaceFile(FString filename, bool& success)
{
success = false;
FString directory = FPaths::Combine(FPaths::ProjectContentDir(), TEXT("MyData"));
TArray<FString> result;
IPlatformFile& file = FPlatformFileManager::Get().GetPlatformFile();
if (file.CreateDirectory(*directory)) {
FString myFile = directory + "/" + filename;
success = FFileHelper::LoadFileToStringArray(result, *myFile);
}
return result;
}