- Home /
Array of list not working when building or running on platforms?
I m using an array of list in my code, its working fine in unity editor but when i tried running it on web player and android device the game stops when array is accessed?
public List[] arrayList = {new List(), new List(), new List(), new List(), new List(), new List()};
Are you giving the Lists types? Such as:
new List()
Odd, I tried to add in a type for the list but it erased it when I hit comment...
I meant this:
new List< Vector3 >()
Yes, I m giving a list type,`
public List<GameObject>[] columnTiles = {new List<GameObject>(), new List<GameObject>(), new List<GameObject>(), new List<GameObject>(), new List<GameObject>(), new List<GameObject>()};
i even tried making a list of list.. which works fine in unity editor but again doesn't work when built.
public List<List<GameObject>> columnTiles;
for(n = 0; n < k; n++)
{
columnTiles.Add(new List<GameObject>());
}
Never tried an array of lists before, but to make the list of lists work you need to initialize the outer List before adding to it...
public List<List<GameObject>> columnTiles = new List<List<GameObject>>();
already done!
m able to run the code on unity editor, code stops working on web player and android device as soon as the list is accessed.
Your answer
![](https://koobas.hobune.stream/wayback/20220613131917im_/https://answers.unity.com/themes/thub/images/avi.jpg)