BLACKISH DEV BLOG Support
 

 

UnityScript: Splitting strings and some type-conversion

How to split a string of values into an array and convert the result from string to float:

var myString : String = “22.1|23.2|26.8|31.4″;
var myStringArray = myString.Split(char.Parse(“|”));
var myFloatArray = new float[myStringArray.length];

for(i = 0; i < myStringArray.length; i++) {
     myFloatArray[i] = parseFloat(myStringArray[i]);
}

Bookmark the permalink. Follow any comments here with the RSS feed for this post. Trackbacks are closed, but you can post a comment.

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>