/*
* loading the record file
*/
private void LoadRecordFile(int selectedRecordFile)
{
Debug.Log(selectedRecordFile.ToString());
string path = recordFilesArray[selectedRecordFile];
Debug.Log(path);
string text = " ";
StreamReader inputStream = new StreamReader(path);
char[] delimiter = { ',' };
while (!text.Equals(null))
{
inputStream.ReadLine();
Debug.Log(text);
text = inputStream.ReadLine().Replace("(", "").Replace(")", "");
string[] values = text.Split(delimiter);
Vector3 vec3;
Quaternion quaternion;
vec3.x = float.Parse(values[0]);
vec3.y = float.Parse(values[1]);
vec3.z = float.Parse(values[2]);
quaternion.x = float.Parse(values[3]);
quaternion.y = float.Parse(values[4]);
quaternion.z = float.Parse(values[5]);
quaternion.w = float.Parse(values[6]);
CarPositionList.Add(vec3);
CarRotationList.Add(quaternion);
}
inputStream.Close();
}
I have this method to read log files. Every time I try to load a log file into my game I get a NullRefernceExcepton:
NullReferenceException: Object reference not set to an instance of an object
CarGameScript.LoadRecordFile (System.Int32 selectedRecordFile) (at
Assets/Scripts/CarGameScript.cs:455)
I alrdy checked if the int value "selectedRecordFile" is null, but it's not. Normally, it should load the lofgfile without an error. The line 455 is:
text = inputStream.ReadLine().Replace("(", "").Replace(")", "");
Any suggestions why am I getting this error?