I’m struggle with JaggedArray for a while now, and still doesn’t see the logic behind them. There nearly nothing about them in documentations, tutorials…
So. In my sphereArray I store all the information about my chessboard, each entry represent 1 cell. In that cell, in hexArray I store position, color, AI reference weight, neighbours and so on. Problem that I have now is that I can’t write to exact cell, somehow i write to every sphereArray element.
var sphereArray : List.<ArrayList> = new List.<ArrayList>(12);
var hexArray = new ArrayList();
function Start () {
hexArray.Add(Vector3);
hexArray.Add(new Array());
hexArray.Add(new int[6]);
~~~
var mesh : Mesh = GetComponent(MeshFilter).mesh;
for (var ij=0; ij < mesh.vertices.length; ij++) {
sphereArray.Add(hexArray);
sphereArray[ij][0] = mesh.vertices[ij];//Текущие координаты
print(sphereArray[ij][0]);
}
print(sphereArray[0][0]);
print("---------------");
print(sphereArray[1][0]);
print("---------------");
print(sphereArray[2][0]);
print("---------------");
Printout i get from “print(sphereArray[ij][0]);” is what I expect to see. Problem is, when I try to receive value from outside of “from” cycle, it’s always gives me last Vector3 i’m writes to Array, no matter what address i’m trying to read. Why this is happening? How should I avoid that?