Ошибка NullReferenceExeption, непонятно, что должно возвращаться
Всем привет, имеется скрипт в Unity на распознование жестов, он записывает и считывает, после запуска сцены, после выполнения считывания зависает с ошибкой NullReferenceExeption. Покажу код
private float AverageDifference(DrawnGesture playerGesture, DrawnGesture template)
{
int numPoints = playerGesture.GetNumPoints();
int tNumPoints = template.GetNumPoints();
if (numPoints != tNumPoints)
{
Debug.Log("Number of points differs from templates");
return -1f;
}
float totalDifference = 0;
for (int i = 0; i < numPoints; i++)
{
totalDifference += PointDistance(playerGesture.GetPoints()[i], template.GetPoints()[i]); // nullreference
}
return (totalDifference / numPoints);
}
Ошибка в строке { totalDifference += PointDistance(playerGesture.GetPoints()[i], template.GetPoints()[i]); // nullreference }
playerGesture и templates берется отсюда
public TwoDPoint[] GetPoints()
{
return points;
}
public void SetPoints(TwoDPoint[] new_points)
{
for(int i = 0; i < numPoints; i++)
{
points[i] = new TwoDPoint(new_points[i].GetX(), new_points[i].GetY());
}
}
Пожалуйста, подскажите что делать, спасибо