05-24-2014, 01:35 PM
The code looks like what I need! I tried it with some colleagues and seem to run into problems like:
In MonoDevelop:
! Line 36 The best overloaded method math for 'CurvySpline.Add(CurvySplineSegment)' has some invalid arguments (CS1502)
! Line 36 Argument '#1' cannot convert 'System.Collections.Generic.List<UnityEngine.Vecotr3>' expression to type 'CurvySplineSegment' (CS1503)
In Unity:
Assets/_Scripts/readTXT2.cs(17,47): error CS1061: Type `System.IO.FileInfo' does not contain a definition for `OpenText' and no extension method `OpenText' of type `System.IO.FileInfo' could be found (are you missing a using directive or an assembly reference?)
We tried a few different way to try to make the script work, perhaps it is an issue with the imported libraries?
Here's what we had so far with the above errors...
[font]using UnityEngine;
using System.Collections;
using System.IO;
using System.Collections.Generic;
public class readTXT2 : MonoBehaviour {
public CurvySpline Spline;
void Start()
{
FileInfo trackFile = new FileInfo ("/Users/lila/Desktop/track11.txt");
TextReader reader = trackFile.OpenText();
int lineNum = 0;
List<Vector3>Points= new List<Vector3>();
string text;
do{
text = reader.ReadLine();
string [] coords = text.Split(' ');
lineNum++;
Points.Add(new Vector3(float.Parse(coords[0]),float.Parse(coords[1]),float.Parse(coords[2])));
//Console.WriteLine(text);
} while (text != null);
Spline.Add(Points);
}
}
Thank you for the code : D I will keep trying using both stream reader and as a text asset. But I wonder if the problem is just with the vector3 list somehow?
Yours,
L[/font]
In MonoDevelop:
! Line 36 The best overloaded method math for 'CurvySpline.Add(CurvySplineSegment)' has some invalid arguments (CS1502)
! Line 36 Argument '#1' cannot convert 'System.Collections.Generic.List<UnityEngine.Vecotr3>' expression to type 'CurvySplineSegment' (CS1503)
In Unity:
Assets/_Scripts/readTXT2.cs(17,47): error CS1061: Type `System.IO.FileInfo' does not contain a definition for `OpenText' and no extension method `OpenText' of type `System.IO.FileInfo' could be found (are you missing a using directive or an assembly reference?)
We tried a few different way to try to make the script work, perhaps it is an issue with the imported libraries?
Here's what we had so far with the above errors...
[font]using UnityEngine;
using System.Collections;
using System.IO;
using System.Collections.Generic;
public class readTXT2 : MonoBehaviour {
public CurvySpline Spline;
void Start()
{
FileInfo trackFile = new FileInfo ("/Users/lila/Desktop/track11.txt");
TextReader reader = trackFile.OpenText();
int lineNum = 0;
List<Vector3>Points= new List<Vector3>();
string text;
do{
text = reader.ReadLine();
string [] coords = text.Split(' ');
lineNum++;
Points.Add(new Vector3(float.Parse(coords[0]),float.Parse(coords[1]),float.Parse(coords[2])));
//Console.WriteLine(text);
} while (text != null);
Spline.Add(Points);
}
}
Thank you for the code : D I will keep trying using both stream reader and as a text asset. But I wonder if the problem is just with the vector3 list somehow?
Yours,
L[/font]