Enter value in Class array how?

My code:

var Cars : CarsInfo[];
class CarsInfo {
var Name : String = "";
var ID : int = 0;
}

function Start () {

  Cars = new CarsInfo[1];
  Cars[0].Name = "Test"; //Dont work! 
  Cars[0].ID = 12;  //Dont work!

}

How enter the value? Thanks! Sorry my English!

1 Answer

1

You need to initialize the items in the array

Cars = new CarsInfo[1];
Cars[0] = new CarsInfo(); //this is the line you need
Cars[0].Name = "Test"; 
Cars[0].ID = 12;