Quantcast
Channel: Latest Questions on Unity Answers
Viewing all articles
Browse latest Browse all 171066

Trying to access a variable within for

$
0
0
Hello, first of all, I want to say I have no background in coding but I am trying to learn it myself through many sources. My question is how to access the "i" value generated by the for loop within my script and use it in another script. (the "var longitude" value) Ultimately I am trying to get plot a set of points (x,z) based on a csv file that I have. Here's the code that I have so far: var csvFile : TextAsset; function Start(){ Longitude(); } function Longitude () { /* split the contents of the file into an array of pieces separated by commas */ var stringArrayLongitude = csvFile.text.Split(","[0]); var stringArrayLatitude = csvFile.text.Split(","[0]); var stringArrayMembers = csvFile.text.Split(","[0]); for(var i = 6; i < stringArrayLongitude.length; i+=4){ var longitude = stringArrayLongitude[i]; } for(var j = 5; j < stringArrayLatitude.length; j+=4){ //print("The latitude is " + stringArrayLatitude[j]); } for(var p = 7; p < stringArrayMembers.length; p+=4){ //print("Number of members is " + stringArrayMembers[p]); } }

Viewing all articles
Browse latest Browse all 171066

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>