示例#1
0
    public static JSONLevel[] GetLevels()
    {
        string json = File.ReadAllText(Application.streamingAssetsPath + JSON_LEVEL_PATH);

        if (string.IsNullOrEmpty(json))
        {
            Debug.Log("Failed");
            return(null);
        }
        JsonLevelWrapper jW = JsonUtility.FromJson <JsonLevelWrapper>(json);

        JSONLevel[] j = jW.levels;
        return(j);
    }
示例#2
0
 public static void WriteJsonLevel(JSONLevel level)
 {
     JSONLevel[] levels = GetLevels();
     for (int i = 0; i < levels.Length; i++)
     {
         if (levels[i].level_name.Equals(level.level_name))
         {
             levels[i] = level;
             JsonLevelWrapper jW = new JsonLevelWrapper();
             jW.levels = levels;
             string j = JsonUtility.ToJson(jW, true);
             File.WriteAllText(Application.streamingAssetsPath + JSON_LEVEL_PATH, j);
             break;
         }
     }
 }