Hey everyone!
I mainly work in blueprints but I do some things like algorithms in c++. My main base classes are also in c++.
I try to create a binary save system following Rama’s tutorial but I’m stuck at the operator << overloads
When I try to save my data it crashes when trying to save a struct. When I comment out the line for the struct it works and the function saves the vector2d and the fstring.
//This is my custom struct
USTRUCT(BlueprintType)
struct FBattleMapTileData
{
GENERATED_BODY()
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Battle Map Data")
TSubclassOf<AMapTile> TileType;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Battle Map Data")
FTransform TileTransform;
};
Now the struct is used in an array and this is how my overload looks like:
FORCEINLINE FArchive& operator<<(FArchive &Ar, FBattleMapTileData TileData)
{
Ar << TileData.TileType;
Ar << TileData.TileTransform;
return Ar;
}
And finally, this is the conversion function:
//SaveLoadData
void ABattleMapCreator::SaveLoadData(FArchive& Ar, TArray<ABattleMapData*> BattleMapData)
{
UE_LOG(BattleMapCreator, Log, TEXT("Attempting binary conversion."));
for (ABattleMapData* map : BattleMapData)
{
Ar << map->MapSize;
Ar << map->MapName;
//Ar << map->MapData;
for (FBattleMapTileData tile : map->MapData)
{
Ar << tile;
}
}
UE_LOG(BattleMapCreator, Log, TEXT("Converted to binary!"));
}
I hope someone can help me! Thanks!
EDIT: Ok, apparently there is a problem with saving a TSubclassOf type. Is there a way do this?