I am struggling to package a game that contains various Sqlite routines which insert and query one database (all using blueprint in v5.02).
All works well in the editor but once its packaged up there is zero functionality in windows.
I have referenced the database folder in the packaging section as an ‘Additional Non-Asset directory to package’ but to no avail. (i do see the database but it isn’t populated with data and the headers /fields are messed up - I even tried putting a copied database in the datafolder once it had packaged but that still didn’t work).
Are there some other settings that i need to adjust that i am missing?
Any help or pointers to a solution/tutorial would be really helpful as I have drawn a blank at the moment and there seems to be very little documentation on the subject.
Hello :).
Are you using the correct path to the db?
This is from my own project, where the paths are specified like:
RelativePathToGMKernel = TEXT("NonAssetData/naif/kernels/Generic/PCK/gm_de431.tpc");
And used like:
FString fullPathToFile = toPath(file);
FString toPath(const FString& file)
{
// BaseGame.ini [/Script/UnrealEd.ProjectPackagingSettings] DirectoriesToAlwaysStageAsNonUFS
// is relative to the project's Content directory... Copying kernel files, then, means the directory must be relative to the content directory
if(FPaths::IsRelative(file))
{
auto gameDir = FPaths::ConvertRelativePathToFull(FPaths::ProjectContentDir());
return FPaths::Combine(gameDir, file);
}
return file;
}
Could you need to set the working directory? I do so like this (windows only):
void furnsh(
const FString& file
)
{
FString fullPathToFile = toPath(file);
#ifdef SET_WORKING_DIRECTORY_IN_FURNSH
// Get the current working directory...
TCHAR buffer[WINDOWS_MAX_PATH];
TCHAR* oldWorkingDirectory = _tgetcwd(buffer, sizeof(buffer)/sizeof(buffer[0]));
// Trim the file name to just the full directory path...
FString fullPathToDirectory = FPaths::GetPath(fullPathToFile);
fullPathToDirectory.ReplaceCharInline('/', '\\');
if (FPaths::DirectoryExists(fullPathToDirectory))
{
// Set the current working directory
_tchdir(*fullPathToDirectory);
}
#endif
furnsh_c(TCHAR_TO_ANSI(*fullPathToFile));
#ifdef SET_WORKING_DIRECTORY_IN_FURNSH
// Reset the working directory to prior state...
if (oldWorkingDirectory)
{
_tchdir(oldWorkingDirectory);
}
#endif
}
Thank you for taking the time to reply, it is really appreciated. I am a C++ philistine i’m afraid and I only use blueprints so the code you provided has ‘gone right over my head’!
Is there a Blueprint alternative?
Mr IMakeVideoGames got me thinking, and he was on the right track, (thanks for that Dude), and I have now found that the issue was mainly down to file location, so for anyone with the same problem, firstly you do need to check the ‘Additional Non-Asset Directories’ box in the game settings packaging section but make sure that you select ‘to copy’ rather than ‘to package’ otherwise you can’t write to it. Secondly, the folder for the databases must be in a folder, (so that you can select the location in the ‘Additional Non-Asset Directories’ box ), and that folder must be a direct descendent (or child) of the contents folder - any sub-sub directories do not work for some reason.
New SQLite3 Plugin: