Hello,
I have been trying to work out a code for awhile now that reads a CSV file, parses the data, and then plots objects based on that data (x,z). Although I am able to parse the CSV file and print the array, I am not understanding how to instantiate objects based on this data.
I have hit a roadblock and really not sure what to do at this point. Does anyone have any suggestions please? Thank you
#pragma strict
//This code is used to parse a CSV file and also to spawn objects based on that CSV fi
// Big thanks to Seth Iacangelo aka Dark Shot of FF XIV
var csvFile : TextAsset;
var prefab : GameObject;
var x = new Array();
var y = new Array();
var z = new Array();
var count = new Array();
var id = new Array();
var j = 0;
function Start(){
Longitude();
print();
}
function Longitude () {
var stringArray = csvFile.text.Replace("
“[0],”,“[0]).Split(”,"[0]);
for(var i = 3; i < stringArray.length; i+=1){
switch (i%3)
{
case 0:
x[j] = stringArray*;*
-
break;*
-
case 1:*
_ y[j] = stringArray*;*_
* break;*
* case 2:*
_ z[j] = stringArray*;
j = j + 1;
break;
}
}
}*_
// Test to see if the array in longitude can be accessed from without. Eventually this code needs to spawn the prefabs
function print(){
* for(var t = 0; t < x.length; t+=1)*
* {*
* var block = Instantiate(prefab);*
* block.transform.position = new Vector3(0+t, 0, 0+t);*
* print("The coordinates for line " + x[t] + " are " + z[t] + “.” + " Height = " + y[t]);*
* }*
}