它正在返回 null 但它已经被定义并应该可以?我猜测这是因为它位于 DontDestroyOnLoad 中,任何人知道一个解决方案或更好的想法?
以下是错误:
“NullReferenceException:对象引用不设置为对象的实例”
以下是代码:
public List<string> hairsUnlocked = new List<string>();
public static SaveBetween instance = null;
public void Awake()
{
if (instance == null)
{
DontDestroyOnLoad(gameObject);
instance = this;
}
else
{
Destroy(gameObject);
}
}
private void Update()
{
hairsUnlocked.Add("TEST");
}
评论 (0)