Does Unity iphone support ArrayList ?
I have the e following piece of code working fine on pc but on my Mac the list contains nothing…(and the print doesn’t print)
It could be because I gone through on the mac and statically typed all the variables but could this have affected the arrayList?
function CreateUniqueRandomArray(desiredArrayLength,min,max) {
//desiredArrayLength=max-min;
//error check if the array is too long for the amount of numbers. It will get stuck in loop.
if(desiredArrayLength>((max-min)))
{
//error
Debug.LogError("Array is too long for the amount of numbers given to fill it");
//set it to the max only. so it wont crash
desiredArrayLength=max-min;
}
var list : ArrayList = new ArrayList();
list.Capacity=desiredArrayLength;
while (list.Count < desiredArrayLength)
{
var number :int= Random.Range(min, max);
if (!list.Contains(number))
{
list.Add(number);
print("One added to list");
}
}
//print out the list of numbers in the log
var logString : String = "UniqueRandomNumbersList: ";
//prints okay!
for (var num : int in list) {
logString += num + ", ";
//doesnt print!
}
Debug.Log(logString);
return list;
}