using System;
using System.Text.RegularExpressions;
using UnityEngine;
namespace FlexFramework.Excel
{
///
/// Default converter for .
///
/// Valid pattern is (x,y,z) where x,y,z are
public sealed class Vector3Converter : CustomConverter
{
///
/// Convert input string to
///
/// Input value
/// Valid pattern is (x,y,z) where x,y,z are
/// Parsed value
/// Vector3 value expression invalid
public override Vector3 Convert(string input)
{
if (!Regex.IsMatch(input, @"^\([-+]?[0-9]*\.?[0-9]+\b,[-+]?[0-9]*\.?[0-9]+\b,[-+]?[0-9]*\.?[0-9]+\b\)$"))
{
throw new FormatException("Vector3 value expression invalid: " + input);
}
string[] parameters = Split(input.Trim('(', ')'), ',');
float x = ValueConverter.Convert(parameters[0]);
float y = ValueConverter.Convert(parameters[1]);
float z = ValueConverter.Convert(parameters[2]);
return new Vector3(x, y, z);
}
}
}