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
Information New free asset: Converter For Unity Splines _Aka_ 5 19 04-25-2024, 11:11 AM
Last Post: _Aka_
  snap to the curve created by the curvy splines segment points ShiroeYamamoto 3 11 04-02-2024, 02:24 PM
Last Post: _Aka_
Bug Changing spline connection in inspector causes splines to revert to defaults lacota 3 6 03-18-2024, 07:55 PM
Last Post: _Aka_
  Using Unity's SplineContainer in Curvy Splines dlees9191 3 15 02-26-2024, 09:49 AM
Last Post: _Aka_

Forum Jump: