使用dreamlo记分板统一获取NullReferenceException

时间:2015-08-29 12:32:45

标签: c# unity3d nullreferenceexception

我正在制作我的第一款游戏并使用dreamlo记分牌资产遇到问题。它基本上是一个简单的排行榜系统,只使用HTTP GET请求,而且没有PhP / SQL。您可以在此处详细了解:Dreamlo

使用随资产一起提供的类,我在这个函数上得到一个NullReferenceException:

public string[] ToStringArray()
{
    if (this.highScores == "") return null;


    string[] rows = this.highScores.Split(new char[] { '\n' }, System.StringSplitOptions.RemoveEmptyEntries);
    return rows;
}

请注意,我的程序运行良好,并且显示了排行榜,但是一旦进入此功能,我就会发现有19个NullReferenceExceptions。

1 个答案:

答案 0 :(得分:1)

详细了解NullReferenceException

试试这一行:

 if (string.IsNullOrEmpty(this.highScores)) return null;