Exemplo n.º 1
0
    //Private

    private void Save()
    {
        SaveFile save = new SaveFile();

        foreach (KeyValuePair <Vector3Int, Block> block in world)
        {
            save.Add(block.Key, block.Value.gameObject.name);
        }
        string json = JsonUtility.ToJson(save);
        string path = Application.persistentDataPath + "/Save.json";

        File.WriteAllText(path, json);
    }
Exemplo n.º 2
0
    public void Write(string key, object value)
    {
        if (currentSaveFile != null)
        {
            bool found = false;
            foreach (SaveDataRow row in currentSaveFile)
            {
                if (row.key == key)
                {
                    row.value = value;
                    found     = true;
                    break;
                }
            }

            if (!found)
            {
                currentSaveFile.Add(new SaveDataRow(key, value));
            }
        }

        SaveToDisk(currentSaveFile);
    }