Forum rules - please read before posting.

Playerprefs question


First of All, Adventure Creator is an amazing product on the asset store, thank you Chris again!

I would have a rare and maybe strange question: I'm developing a game and I use dialogue system from AC, and I have an own save-load script and I would like to save and load the AC variables into/from Playerprefs too, so I want to write it(AC variables) in my save-load script. What should I write into the script at save/load part? I hope I could write it clearly. Please, if not ask me, and I try to explain it again better!:))


  • AC can already save particular AC Global variables in PlayerPrefs by setting their Link to property to Options Data. This will store their values in PlayerPrefs as part of the active profile (along with things like SFX volume and the active language), as opposed to save game files.

    It's also possible to have AC store all its data in PlayerPrefs with:

    SaveSystem.SaveFileHandler = new SaveFileHandler_PlayerPrefs ();

    To save and load Global variables by custom means, though, you need to condense all the variable data (their IDs and values) into a single string. AC provides a function to do this:

    string myGlobalVariableData = SaveSystem.CreateVariablesData (GlobalVariables.GetAllVars (), false, VariableLocation.Global);

    You can then store this in PlayerPrefs with SetString.

    To load them again, AC provides another function to decompress such string data back into the current Gobal variable values:

    SaveSystem.AssignVariables (myGlobalVariableData);
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.