Hi! I was just wondering how the popup variable works in script.
Basically I'm in need of saving a few groups of ints (for a List of Data classes. Each data class only holds ints, 10 ints). Now, I need 7 groups of ints (they're basically date's information, like, month, year, day of the week, weather type, etc). I was thinking how I could save these using AC globals in a clean way (I don't want to make 70 single int variables if possible). So, the first thing that came to mind were the popup variables. But I notice they are strings, not ints. So I'm not sure how that'd go since I've never used that variable type in script. Is it possible to return an array with the whole data? or would I need to get the data one by one?
Else, what is the way that AC deals with saving global variable data? I have some code I can use to serialize Data classes but I've never had to deal with profiles before. I mostly leave that to AC. Plus, I've no clue how AC is dealing with profiles itself, and it worries me saved data won't be in sync with AC's profiles.
Anyone has any tips to deal with this situation?
Anyway, any advice will be greatly appreciated.
Comments
You can store anything in the String type, as you can convert integers to strings with .ToString(), and use parsing (e.g. int.TryParse) to convert them back. You can also merge integers together by separating them with e.g. a colon, and then splitting them into an array when loading.
Per-profile / Options data is stored in PlayerPrefs, to keep them independent from save game data. You can set a Global Variable to be recorded in Options data from the Variables Manager - see this tutorial.
Global Variables are stored within the "vars" GVar List in Variables Manager. You don't need to open the source code, as it's in the scripting guide:
AC.KickStarter.variablesManager.vars
EditorUtility.SetDirty (AC.KickStarter.variablesManager);
More info here: https://docs.unity3d.com/ScriptReference/EditorUtility.SetDirty.html