I get a strange error when I try to take the data out of a csv file. I get : error CS1525: Unexpected symbol txt', expecting)', or `.'
Here is my script
using UnityEngine;
using System.Collections;
public class Mindthecube : MonoBehaviour {
// Use this for initialization
void Start () { FileInfo theSourceFile = null;
TextReader reader = null; // NOTE: TextReader, superclass of StreamReader and StringReader
// Read from plain text file if it exists
theSourceFile = new FileInfo (Application.dataPath + "/puzzles.txt");
if ( theSourceFile != null && theSourceFile.Exists )
{
reader = theSourceFile.OpenText(); // returns StreamReader
}
else
{
// try to read from Resources instead
TextAsset puzdata = (TextAsset)Resources.Load("puzzles", typeof(TextAsset));
reader = new StringReader(puzdata.text); // returns StringReader
}
if ( reader == null )
{
Debug.Log("puzzles.txt not found or not readable");
}
else
{
// Read each line from the file/resource
while ( (string txt = reader.ReadLine()) != null )
Debug.Log("-->" + txt);
}
}
}
asked
Nov 11 '11 at 10:08 PM
gtm1260
1
●
3
●
3
●
3