Under review

[Tip] Save specific data without SaveLoadManager

JOON 4 months ago in Game Creator updated by Marti (Lead Developer) 4 months ago 3

Hello everyone

I am trying to make score & ranking system for my game. GC has awesome SaveLoadManager, but it can save & load for game scene. perhaps, there are someone who looking for saving&loading data regardless Save/Load game scene.

For game-option system or local-ranking system, I explain my idea about saving/loading specific data with GC.

According to script of SaveLoadManager of GC, it uses DatabaseGeneral for saving & loading.
so we can use it too to save & load specific game data

for example, I made prototype of GameRanking system like below

first, you need to make serializable class which will store specific data for you :)

because you will parse it to json string, so you need to attach [serializable]

and, unityEngine has smart JsonUtility for handling json strings.

I made one wrapper class to handle List 
I don't know the reason, but I can't handle a list directly without handler class to make json string with JsonUtility of UnityEngine.

if you can handle json string with your serializable class and JsonUtility, then you can save & load the json string with  DatabaseGeneral of GC like below;

the most important thing is the unique key, the unique key is the unique key string to recognize specific json object which you want. it must be unique, if it has same value with another saved items, it will overwrite on another data


Unity version:
Game Creator version:

Thank you for the ideas on expanding GC save/load abilities using Json. I'm looking into ways to save complex information using JSON that will integrate easily with GC's save/load system.

An alternate approach I'm considering would use both Json and GC's save/load feature.

  1. Create a GC global variable set to string that is saved (named "GCSaveThisForMe")
  2. Write my C# to build my complex data structure and use Unity's JsonUtility to convert it to a string ("JsonStringOutput").
  3. Call GC's Variables API  SetGlobal(GCSaveThisForMe, JsonStringOutput) before calling GC save game action.
  4. After GC load game action is loaded, do the reverse. 

Note for coders/non-coders: this approach may makes sense if you are writing your code. This can increase flexibility and scope of your game, but with some danger https://en.wikipedia.org/wiki/Hoist_with_his_own_petard.

I have these concerns my approach.

  • Performance of copy a really long string, which would add to the time it takes to save the game.
  • Some not obvious limitation on string length less than the known limit of 4 billion characters (2^32).
  • Weird combinations of characters in the data being saved not getting escaped correctly in and out Json and causing grief.

Any thoughts or additional concerns?


Saving data is always big issues to create & manage games. according to google, C# string type can hold 1 billion characters as maximum limit. I think it is around 2 GB.

saving large data with Json string is not good idea in my opinion. if you handle large string file to read with parser, the parser will spend a lot of time to read. I guess the save game data to load current game scene is not too much big like that. maybe, you can prints the length of string as Log.

if you want to faster save & load methods to handle large data, maybe you can save binery data into file, or you can use database on your own server. but even if you save every player's logs on your own sever, 2gb for each players is too much big data. 

if you worried about the json string will be broken with weird characters, you can encode string values which you want to save into json. there are some encoding method to help you. I recommand base64 is good encoding options for you.

base64 can encode any strings (actually not only strings) with Ascii letters. so you don't need to worry about weird characters which can broken json data. because base64 can encode binary data into ascii strings, you can hold image file as base64 string. and html img tag can use base64 string directly. so I recommand base64 is one of safe option to handle weird data. the only weakness point of base64 is it can enlarge it's size

Under review

Joon I wasn't aware there was a 2GB limit of storage for strings. Although the limit is very high and no game will probably reach it (as GC does a very good job of only storing what's necessary instead of redundant data or unusefull data), I agree that this could potentially be dangerous.

The good thing is that the Data Provider class allows to change how you store data. You can store it using the Binary Formatter class and split it into multiple files or so.

I'll open a ticket for research. I've been wanting to work on the Save/Load system for a while now and this gives me the perfect excuse to do so.