Skip to content

Instantly share code, notes, and snippets.

@jorgenpt
Created October 7, 2012 21:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jorgenpt/3849735 to your computer and use it in GitHub Desktop.
Save jorgenpt/3849735 to your computer and use it in GitHub Desktop.
static public Vector3 ParseVector3(string input) {
input = input.TrimStart('(').TrimEnd(')')
string[] components = input.Split(',');
Vector3 output = Vector3.zero;
if (components.Length > 0) {
try { output.x = float.Parse(components[0]); } catch (Exception e) {}
}
if (components.Length > 1) {
try { output.y = float.Parse(components[1]); } catch (Exception e) {}
}
if (components.Length > 2) {
try { output.z = float.Parse(components[2]); } catch (Exception e) {}
}
return output;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment