Thẻ

[1] Download Json.net
http://www.newtonsoft.com/json
[2] Copy to unity project
[3] Create file data.json in Resources folder

[4] Write:
File.WriteAllText(Application.dataPath + @”\Resources\data.json”, JsonConvert.SerializeObject(new UserData()));

[5] Read:
UserData a = JsonConvert.DeserializeObject(File.ReadAllText(Application.dataPath + @”\Resources\data.json”));

nguồn: https://theodorsolbjorg.wordpress.com/2013/11/16/unity3d-save-game-json-net/

Advertisements