https://www.mediafire./convkey/7d2b/fr75kbso2kkazru6g.jpg
Dear Community,
I have been hard at work making UE4 C++ Code tutorials!
I have added many pages of entirely code-focused tutorials, including both .h and .cpp,
to the UE4 Wiki Code Page!
https://wiki.unrealengine./Category:Code
**UE4 C++**
The entire focus of these tutorials is UE4 C++, not just regular C++.
Using my code samples will help you get a feel of how UE4 C++ works and help you get integrated with the UE4 API.
**Code Example
Custom Save System To Compressed Binary File**
Here’s a sample of the kind of code I am posting on the Wiki Code page:
is a code sample for how to Save any game data you want from UE4 C++ to a compressed binary filename of your choosing.
bool ControllerClass::SaveGameDataToFileCompressed(const FString& FullFilePath,
int32& SaveDataInt32,
FVector& SaveDataVector,
TArray<FRotator>& SaveDataRotatorArray
){
FBufferArchive ToBinary;
SaveLoadData(ToBinary,NumGemsCollected,PlayerLocation,ArrayOfRotationsOfTheStars);
**//Pre Compressed Size**
ClientMessage("~ PreCompressed Size ~");
ClientMessage(FString::FromInt(ToBinary.Num()));
//
**// Compress File
//tmp compressed data array**
TArray<uint8> CompressedData;
FArchiveSaveCompressedProxy Compressor =
FArchiveSaveCompressedProxy(CompressedData, ECompressionFlags::COMPRESS_ZLIB);
**//Send entire binary array/archive to compressor**
Compressor << ToBinary;
**//send archive serialized data to binary array**
Compressor.Flush();
//
**//Compressed Size**
ClientMessage("~ Compressed Size ~");
ClientMessage(FString::FromInt(CompressedData.Num()));
if (!GFileManager) return false;
**//vibes to file, return successful or not**
if (FFileHelper::SaveArrayToFile(CompressedData, * FullFilePath))
{
**// Free Binary Arrays **
Compressor.FlushCache();
CompressedData.Empty();
ToBinary.FlushCache();
ToBinary.Empty();
**// Close Buffer **
ToBinary.Close();
ClientMessage("File Save Success!");
return true;
//
}
else
{
**// Free Binary Arrays **
Compressor.FlushCache();
CompressedData.Empty();
ToBinary.FlushCache();
ToBinary.Empty();
**// Close Buffer **
ToBinary.Close();
ClientMessage("File Could Not Be Saved!");
return false;
//
}
}
**Summary**
Enjoy!