using UnityEngine; using System.Globalization; using System.Collections.Generic; using System.IO; using System; public class ReadFromCSV : MonoBehaviour { //private void Start() //{ // string dir = Directory.GetCurrentDirectory(); // string reference = @"\Assets\CSV_files\Walk1.txt"; // List vec = ReadFromTxtFile(dir + reference); //} //Reads from csv files public Tuple, List> ReadFromCSVFile(string path) { if(!File.Exists(path)) { return null; } List posList = new List(); List rotList = new List(); using (StreamReader reader = new StreamReader(path, true)) { // Skip header reader.ReadLine(); while (!reader.EndOfStream) { var line = reader.ReadLine(); var values = line.Split(';'); // Adding into position list posList.Add(new Vector3( float.Parse(values[0]), float.Parse(values[1]), float.Parse(values[2]))); // Adding into rotation list rotList.Add(new Quaternion( float.Parse(values[3]), float.Parse(values[4]), float.Parse(values[5]), float.Parse(values[6]))); } } return Tuple.Create(posList, rotList); } }