我对c#和团结相当新。我试图从我的json文件中获取变量,但该程序似乎只能正确返回布尔值和字符串。
C#
public class Reputation
{
public int normal { get; set; }
}
void Start()
{
string reputation = @"c:\path\to\file\reputation.json";
StreamReader reader2 = new StreamReader (reputation);
player.reputation = JsonUtility.FromJson<Reputation>(reader2.ReadToEnd ());
reader.Close ();
Debug.Log(player.reputation.normal);
}
JSON
{
"normal":20
}
并且日志显示0