|
@@ -16,5 +16,25 @@ namespace MeidoPhotoStudio.Converter.MultipleMaids
|
|
|
var data = vector3.Split(',');
|
|
|
return new(float.Parse(data[0]), float.Parse(data[1]), float.Parse(data[2]));
|
|
|
}
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// Checks if the string has 3 euler angle components delimited by commas before parsing
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="euler">Euler angle string in the form "x,y,z"</param>
|
|
|
+ /// <param name="result">Resulting angle as a <c>Quaternion</c></param>
|
|
|
+ /// <returns>Whether or not the euler string can be safely parsed</returns>
|
|
|
+ public static bool TryParseEulerAngle(string euler, out Quaternion result)
|
|
|
+ {
|
|
|
+ result = Quaternion.identity;
|
|
|
+
|
|
|
+ var data = euler.Split(',');
|
|
|
+
|
|
|
+ if (data.Length != 3) return false;
|
|
|
+
|
|
|
+ try { result = Quaternion.Euler(float.Parse(data[0]), float.Parse(data[1]), float.Parse(data[2])); }
|
|
|
+ catch { return false; }
|
|
|
+
|
|
|
+ return true;
|
|
|
+ }
|
|
|
}
|
|
|
}
|