My solution post jump link:
http://forum.unity3d.com/viewtopic.php?p=300180#300180
Ok, long story short, I’ve got blocks in an editor with positions being saved using the command Vector3.toString().
I can retrieve the string no problem, but then I get this in string format:
(0.0,0.0,0.0)
I need to get that back into a Vector3 object. Aka, an object formed by doing this:
var newBlockVector = Vector3(x,y,z);
The long way to do this would be to parse the string using “,” as the character to parse with, calculating for the ()s placed around the number too. But that’s several lines of code and three new variables to do basically the reverse of what Vector3.toString() did.
I can’t help but feel there must be an easier way, but I can’t find one in the manual. Is there an easier way to take the result of Vector3.toString(), and plug it back into a Vector3 object?
I basically need an “opposite” or “back conversion” for Vector3.toString(). Is there one, or do I have to stick with the long, string parsing while chopping off the ()s, way?
Edit: Ok, my method isn’t working either. I’ve got the string cut down to three variables, but they are still string type so Unity won’t accept them as valid values in the Vector3(x,y,z) constructor. How do I convert a string to a value I can plug into Vector3(x,y,z) constructor? (I know these will always be numbers as returned by Vector3.toString, so the user won’t be able to put funky things like “bob” into the formula.)