Last active
March 2, 2024 19:33
-
-
Save alfredbaudisch/11c2f2c13402b9f524398b7bd54885c9 to your computer and use it in GitHub Desktop.
Unreal Engine Run Counter from the Editor (to keep track of how many times you run/launch/playtest the game during development)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "Core/YourGameInstance.h" | |
void UYourGameInstance::Init() | |
{ | |
Super::Init(); | |
// Do stuff.. | |
#if WITH_EDITOR | |
FString FilePath = FPaths::ConvertRelativePathToFull(FPaths::ProjectDir()) + TEXT("/GameLaunches.txt"); | |
FString LoadedFile; | |
FFileHelper::LoadFileToString(LoadedFile, *FilePath); | |
int32 GameLaunches = 1; | |
if (!LoadedFile.IsEmpty()) | |
{ | |
GameLaunches = FCString::Atoi(*LoadedFile) + 1; | |
} | |
LoadedFile = FString::FromInt(GameLaunches); | |
FFileHelper::SaveStringToFile(LoadedFile, *FilePath, FFileHelper::EEncodingOptions::AutoDetect, | |
&IFileManager::Get(), EFileWrite::FILEWRITE_None); | |
#endif | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment