-1
我想從外部數據文件讀取文件,將它們粘貼到數組中以導入到Unity3D。 於是我開始這樣的:將文件中的值讀入多維數組
int [,] positionTab = new int[noLoc,3];
StreamReader sr = new StreamReader(myTextFile);
while((line = sr.ReadLine()) != null)//read line by line up to the end
{
if (line.Contains("confTrain1"))
{
locationTrain1 = RetrieveValueInDataFile.locationTrain(line);
}
else if (line.Contains("confTrain2"))
{
locationTrain2 = RetrieveValueInDataFile.locationTrain(line);
}
else
{
distanceBetweenThem =RetrieveValueInDataFile.distBetweenTrain(line);
}
我不知道有這樣的:
int [,] locations = new int [noLoc, 3]
{
{locationTrain1, locationTrain2, distanceBetweenThem}
{locationTrain1, locationTrain2, distanceBetweenThem}
{etc}
}
的問題是我不知道如何做到這一點的StreamReader的。我的意思是,我如何添加兩個位置和距離(語法)?
好吧,我會試試這個。謝謝。 – AuroreT