Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
splines from .txt files
#9
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>Pointsnew 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]
 
Reply


Messages In This Thread
splines from .txt files - by Lila - 04-30-2014, 01:18 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Connections Between Opposing Splines lockiidraws 1 596 12-04-2025, 02:14 PM
Last Post: _Aka_
  Spawn at start/ end of splines rickgplus 4 2,888 03-21-2025, 12:34 PM
Last Post: _Aka_
  Any performance 'hacks' for scene with lots of splines rickgplus 1 1,825 03-18-2025, 10:11 PM
Last Post: _Aka_
Smile Simple splines movement shills 3 3,236 02-26-2025, 09:40 AM
Last Post: _Aka_

Forum Jump: