Monday, June 16, 2014

Unity C# AOT error on 4 dimensional arrays

When building for iOS with unity I found a new (to me) AOT error. Creating  4 dimensional array like

bool[,,,] combos = new bool[2,2,2,2];

works on no iOS platforms but will throw a runtime error on iOS.

bool [][][][] combos = new bool[2][][][];

works fine although you will need to initialise it in a messy set of loops

combos = new bool[2][][][];
for(int i = 0;i<;2;i++){
 combos[i] = new bool[2][][];
 for(int j =0;j<2;j++){
  combos[i][j] = new bool[2][];
  for(int k =0;k<2;k++){
   combos[i][j][k] = new bool[2];
  }
 }
}

No comments: