12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- using UnityEngine;
- using System.Globalization;
- using System.Collections.Generic;
- using System.IO;
- using System;
- public class ReadPosFromFile : MonoBehaviour
- {
-
-
-
-
-
-
-
- public List<Vector3> ReadFromTxtFile(string path)
- {
- if(!File.Exists(path))
- {
- return null;
- }
-
- List<Vector3> vec = new List<Vector3>();
- char[] seperator = new char[] { ',' };
- foreach (string line in File.ReadLines(path))
- {
- if(line != null)
- {
-
- string lineCleaned = line.Substring(1, line.Length - 2);
- string[] lineSplited = lineCleaned.Split(seperator, StringSplitOptions.RemoveEmptyEntries);
- vec.Add(new Vector3(
- float.Parse(lineSplited[0], CultureInfo.InvariantCulture),
- float.Parse(lineSplited[1], CultureInfo.InvariantCulture),
- float.Parse(lineSplited[2], CultureInfo.InvariantCulture)));
- }
- }
- return vec;
- }
- }
|