我有以下单身人士:
public class SingletonGM: MonoBehaviour {
public static SingletonGM Instance { get; private set; }
public List<Info> listinfo= new List<Info>();
void Awake(){
if (Instance == null)
Instance = this;
else if (Instance != this)
Destroy (gameObject);
}
public class Info
{
public int score;
}
}
我试图从另一个脚本访问得分字段,如下所示:
SingletonGM.Instance.listinfo[0].score = 10;
我得到:&#34;对象引用未设置为对象的实例&#34;。为什么会这样?谢谢!