Hi!
I have level that consists of cubes. it will be vary in size but lets say it will be like this
width: 8 cubes
heigth 8 cubes
length 16 cubes
cube is 1 scale
I currently generate it by looping and translating by 1 unit like this:
IEnumerator Create()
{
for (int i = 0; i < Length; i++)
{
for (int j = 0; j < Height; j++)
{
for (int k = 0; k < Width; k++)
{
var g = NGUITools.AddChild(Root, Prefab);
if (g != null)
{
g.transform.position = Vector3.zero;
g.transform.rotation = Quaternion.identity;
g.transform.Translate(new Vector3(k-Width/2f+ 0.5f,j-Height/2f+ 0.5f,i-Length/2f+ 0.5f));
}
yield return null;
}
}
}
}
I used NGUITools.AddChild because cube has some ui elements that are displayed on one of its sides. this propery creates the cubes, i am just wondering how to store this information so i can easily access cubes that are on the surface or by some meanful way. any ideas? jagged arrays? lists,dict or something else?
any idea is appreciated!