Ok, I have a text file with coordinates separated by commas that looks like this:
234,252,435,234,334,345 … and so on…
I want to use that as a TextAsset and split it into an array (I’m guessing)
var stringArray = myTextFile.text.Split(","[0]);
Then I need to split that again into each set of 3 as x,y,z,x,y,z,x,y,z,…
Then instantiate a prefab at each set of x,y,z, etc…
Basically I want to instantiate a whole bunch of prefabs and get their positions from a simple csv file (which I want to get streaming from outside data eventually, hence no line breaks)
Can anyone please help me figure out how to do this?! I’ve read the docs till my eyes are red…
This is totally wrong and I’ve tried a hundred versions of it but here is my code. I’m trying to keep it short…
var myTextFile : TextAsset;
var pixel : Transform;
function Start () {
MakeShape();
}
function MakeShape () {
var stringArray = myTextFile.text.Split(","[0]);
for ( var i = 0; i < stringArray.length; i ++ ) {
x=i; i++;
y=i; i++;
z=i; i++;
}
transform.position = Vector3(x, y, z);
Instantiate (pixel, transform.position, Quaternion.identity);
}