示例#1
0
    public void SaveScriptInJSON()
    {
        NumberForJson number = new NumberForJson();

        number.Current = int.Parse(InputBox.text);
        string json = JsonUtility.ToJson(number);

        File.WriteAllText(Application.dataPath + "Number.json", json);
    }
示例#2
0
 public void WriteCurrentInTextFromJson()
 {
     try
     {
         string        json   = File.ReadAllText(Application.dataPath + "Number.json");
         NumberForJson number = JsonUtility.FromJson <NumberForJson>(json);
         current.text = "Current Number:" + number.Current;
     }
     catch (System.Exception e)
     {
         Debug.Log(e.Message);
     }
 }