using System.Collections.Generic; using UnityEngine; public static class DataParse { public static Color ToColor(this string str) { string[] strings = str.Split(' '); return new Color(float.Parse(strings[0]), float.Parse(strings[1]), float.Parse(strings[2]), float.Parse(strings[3])); } public static string ToStr(this Vector3 vector) { return $"{vector.x} {vector.y} {vector.z}"; } public static string ToStr(this Vector3 vector, int accuray) { string accurayStr = $"F{accuray}"; return $"{vector.x.ToString(accurayStr)} {vector.y.ToString(accurayStr)} {vector.z.ToString(accurayStr)}"; } public static Vector3 ToVector(this string str) { string[] strings = str.Split(' '); return new Vector3(float.Parse(strings[0]), float.Parse(strings[1]), float.Parse(strings[2])); } public static string ToStr(this Transform transform) { return $"{transform.position.x} {transform.position.y} {transform.position.z} {transform.eulerAngles.x} {transform.eulerAngles.y} {transform.eulerAngles.z}"; } public static Vector3[] ToTransform(this string str) { string[] strings = str.Split(' '); Vector3[] vectors = new[] { new Vector3(float.Parse(strings[0]), float.Parse(strings[1]), float.Parse(strings[2])), new Vector3(float.Parse(strings[3]), float.Parse(strings[4]), float.Parse(strings[5])), }; return vectors; } }