| | | 1 | | using System.Collections.Generic; |
| | | 2 | | using UnityEngine; |
| | | 3 | | |
| | | 4 | | // 2D interpolator data point. |
| | | 5 | | public class Interpolator2DDataPoint { |
| | | 6 | | // 2D coordinates. |
| | 4376 | 7 | | public Vector2 Coordinates { get; init; } |
| | | 8 | | |
| | | 9 | | // Arbitrary data consisting of floats. |
| | 726 | 10 | | public IReadOnlyList<float> Data { get; init; } |
| | | 11 | | |
| | | 12 | | // Validate and parse the data from strings to floats. |
| | 573 | 13 | | public static (bool, List<float>) ValidateAndParseData(string[] values) { |
| | 573 | 14 | | var parsedValues = new List<float>(); |
| | 7925 | 15 | | for (int i = 0; i < values.Length; ++i) { |
| | 2273 | 16 | | if (!float.TryParse(values[i], out float parsedValue)) { |
| | 8 | 17 | | return (false, new List<float>()); |
| | | 18 | | } |
| | 2257 | 19 | | parsedValues.Add(parsedValue); |
| | 2257 | 20 | | } |
| | 565 | 21 | | return (true, parsedValues); |
| | 573 | 22 | | } |
| | | 23 | | } |