- Home /
Question by
metaphysician · Feb 26, 2017 at 04:13 AM ·
arraysmultidimensional array
need to get 2D array from 3D array of custom class
hey folks, if i start with a 3D array of a custom class, how can i copy the contents to and from a 2D array class? i want to be able take a cube of objects, separate the layers, edit each layer and then put it back into the cube.
i start with something like this:`public static CellData[,,] constellationInstance = new CellData[8,8,8];`
and then i can initialize them with information like so:
for (int i = 0; i < 8; ++i)
for (int j = 0; j < 8; ++j)
for (int k = 0; k < 8; ++k){
constellationInstance[k,j,i] = new CellData();
constellationInstance[k,j,i].cellEnabled=false;
constellationInstance[k,j,i].cellIntensity=100;
GameObject cellObj = GameObject.Find("Constellation/Layer_"+k+"/Row_"+rowNames[j]+"/pos"+i);
cellObj = cellObj.transform.GetChild(0).transform.gameObject;
constellationInstance[k,j,i].cellObject = cellObj;
}
}
but in another script i want to make a copy of one layer of that cube - take the first layer (0,j,i for example), copy that to a 2D layer of CellData. how can i do this?
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612111947im_/https://answers.unity.com/themes/thub/images/avi.jpg)