Code (csharp): using UnityEngine; using System.Collections; using System; public class test : MonoBehaviour { IEnumerator Start () { int a = 1; int f = 1; string url = "http://www.decadesband.com/uploads/2/8/0/0/2800976/song_data.csv"; WWW www = new WWW (url); yield return www; String [,] basic = new String [2,7]; String [] split = www.text.Split(new Char [] {',',' '}); foreach (String s in split) { if(a<3) { basic[a,f] = s; f += 1; if(f>7) { f=1; a+=1; } } } Debug.Log(basic[1,5]); } void Update () { } } Error log i recieved IndexOutOfRangeException: Array index is out of range. test+<Start>c__Iterator0.MoveNext () (at Assets/test.cs:19)
Means you are trying to access a item in the array which does not exist for example: GameObject[] gos = new GameObject[10]; we can see there should be 10 elements in the array. They start at 0 and end 9 (0 to 9 = 10), so if i did gos[10] i would get an out of range exception.
should be Code (csharp): foreach (String s in split) { if(a<2) // 3 changes to 2 { basic[a,f] = s; f += 1; if(f>7) { f=1; a+=1; } } } since array indexes start from 0