C# 如果我的C JSON.text文件被删除或值被更改,则需要该文件具有默认高分(UNITY)
如何通过C将默认的int和string name值添加到JSON.txt中?我将首先创建默认的HighScore集合,其中包含所有这些假玩家:C# 如果我的C JSON.text文件被删除或值被更改,则需要该文件具有默认高分(UNITY),c#,json,unity3d,save,C#,Json,Unity3d,Save,如何通过C将默认的int和string name值添加到JSON.txt中?我将首先创建默认的HighScore集合,其中包含所有这些假玩家: private List<Score> scores = null; void Start() { this.scores = new List<Score>() { new Score("Adam", 10000), new Score("Eve",7500); // ... };
private List<Score> scores = null;
void Start()
{
this.scores = new List<Score>()
{
new Score("Adam", 10000), new Score("Eve",7500); // ...
};
Score[]scores = GetJsonFileWithScore(); // This is where you get the real players score
this.scores.AddRange(scores);
this.scores.OrderBy (s => s.score); // Order it by score
int index = 4;
this.scores.RemoveRange(index, list.Count - index); // keep only the best 5
}