I’m trying to recreate the JSon save game system posted on UDK Gems, so I created a class which will have static methods to save and load a game.
// Copyright 1998-2013 Epic Games, Inc. All Rights Reserved.
#pragma once
#include "SaveGameSystem.generated.h"
/**
*
*/
//UCLASS()
//class USaveGameSystem : public UObject
class FSaveGameSystem
{
public:
//GENERATED_UCLASS_BODY()
static bool SaveGame(const FString& FileName)
{
bool bSuccess = false;
FBufferArchive ToBinary;
int32 x = 12312;
float y = 25234.f;
ToBinary << x;
ToBinary << y;
bSuccess = FFileHelper::SaveArrayToFile(ToBinary, FileName);
ToBinary.FlushCache();
ToBinary.Empty();
return bSuccess;
}
};
The above code compiles, but, if I call this from another file, for exemple from the ShooterCharacter:
FSaveGameSystem::SaveGame("Quicksave.save");
I get the errors:
error C2653: 'FSaveGameSystem' : is not a class or namespace name
error C3861: 'SaveGame': identifier not found
I tried adding #include "SaveGameSystem.h"
to the top of ShooterCharacter.cpp
, didn’t work. I also checked if SaveGameSystem.h
is in ShooterGameClasses.h
, it is not. I also tried a rebuild / deleting Intermediate/BuildData
.
So the question is: how to properly create a non-object class, and make it globally accessible?
Also, I have another, related question: #include "SaveGameSystem.generated.h"
is only necessary for Object-extending classes, right? If I remove that line, I get compile errors telling me to put it back.
PS. Sorry, once again I forgot to put it on the right section