Created
September 6, 2022 20:33
-
-
Save Cdddo/41f6d8944f846fa14ba76467a7b39602 to your computer and use it in GitHub Desktop.
yanr save to json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private string SerializeAllVariablesToJSON() | |
{ | |
(var floats, var strings, var bools) = _variableStorage.GetAllVariables(); | |
SaveData data = new SaveData(); | |
data.floatKeys = floats.Keys.ToArray(); | |
data.floatValues = floats.Values.ToArray(); | |
data.stringKeys = strings.Keys.ToArray(); | |
data.stringValues = strings.Values.ToArray(); | |
data.boolKeys = bools.Keys.ToArray(); | |
data.boolValues = bools.Values.ToArray(); | |
return JsonUtility.ToJson(data, true); | |
} | |
[System.Serializable] | |
private struct SaveData | |
{ | |
public string[] floatKeys; | |
public float[] floatValues; | |
public string[] stringKeys; | |
public string[] stringValues; | |
public string[] boolKeys; | |
public bool[] boolValues; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment