Hello, I am looking to instantiate a series of objects from a parsed CSV file. I am able to print the parsed data however I am not really sure how to instantiate them based on the CSV file (x y locations for example). Please, any direction or help would be appreciated as I am still very new to coding in general.
The entire code can be found below here:
var csvFile : TextAsset;
var cube : GameObject;
var instantiate : GameObject;
var x = new Array();
var y = new Array();
var lon = new Array();
var count = new Array();
var id = new Array();
var j = 0;
function Start(){
Longitude();
printDebug();
print();
}
function Longitude () {
var stringArray = csvFile.text.Replace("
“[0],”,“[0]).Split(”,"[0]);
for(var i = 2; i < stringArray.length; i+=1){
switch (i%2)
{
case 0:
x[j] = stringArray*;*
-
break;*
-
case 1:*
_ y[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 z = 0; z < x.length; z+=1)*
* {*
* var cube : Transform;*
* Instantiate(cube, x[z].position, Quaternion.identity);*
* print("The coordinates for line " + x[z] + " are " + y[z] + “.”);*
* }*
}