void Init() { int x; int y; int z; blocks = new McBlock[BlockCountX, BlockCountY, BlockCountZ]; values = new McValues(this); McBlock _mcBlock; GameObject _mcBlockGO; sizeX = BlockCountX * BlockResX; sizeY = BlockCountY * BlockResY; sizeZ = BlockCountZ * BlockResZ; float _h = (1 / BlockCountX); _h += (_h * 0.5f); mid = new Vector3((1f / sizeX) / 2, (1f / sizeY) / 2, (1f / sizeZ) / 2); for (x = 0; x < BlockCountX; x++) { for (y = 0; y < BlockCountY; y++) { for (z = 0; z < BlockCountZ; z++) { _mcBlockGO = new GameObject("MC Block: " + x + "," + y + "," + z); _mcBlockGO.transform.parent = transform; _mcBlock = _mcBlockGO.AddComponent <McBlock>(); _mcBlock.mcField = this; blocks[x, y, z] = _mcBlock; _mcBlock.posX = x; _mcBlock.posY = y; _mcBlock.posZ = z; _mcBlock._dimX = BlockResX; _mcBlock._dimY = BlockResY; _mcBlock._dimZ = BlockResZ; _mcBlock.transform.position = new Vector3((1f / BlockCountX) * x, (1f / BlockCountY) * y, (1f / BlockCountZ) * z); _mcBlock.transform.position += Vector3.one * (1f / BlockCountX) * 0.5f; _mcBlock.transform.position -= Vector3.one * 0.5f; _mcBlock.transform.position += transform.position; _mcBlock.transform.localScale = new Vector3(1f / BlockCountX, 1f / BlockCountY, 1f / BlockCountZ); } } } }
void Init() { int x; int y; int z; blocks = new McBlock[BlockCountX,BlockCountY,BlockCountZ]; values = new McValues(this); McBlock _mcBlock; GameObject _mcBlockGO; sizeX = BlockCountX * BlockResX; sizeY = BlockCountY * BlockResY; sizeZ = BlockCountZ * BlockResZ; float _h = (1 / BlockCountX); _h += (_h*0.5f); mid = new Vector3( (1f / sizeX) / 2, (1f / sizeY) / 2, (1f / sizeZ) / 2); for(x=0;x<BlockCountX;x++) { for(y=0;y<BlockCountY;y++) { for(z=0;z<BlockCountZ;z++) { _mcBlockGO = new GameObject("MC Block: " + x + "," + y + "," + z); _mcBlockGO.transform.parent = transform; _mcBlock = _mcBlockGO.AddComponent<McBlock>(); _mcBlock.mcField = this; blocks[x,y,z] = _mcBlock; _mcBlock.posX = x; _mcBlock.posY = y; _mcBlock.posZ = z; _mcBlock._dimX = BlockResX; _mcBlock._dimY = BlockResY; _mcBlock._dimZ = BlockResZ; _mcBlock.transform.position = new Vector3((1f / BlockCountX) * x,(1f / BlockCountY) * y,(1f / BlockCountZ) * z); _mcBlock.transform.position += Vector3.one * (1f / BlockCountX) * 0.5f; _mcBlock.transform.position -= Vector3.one * 0.5f; _mcBlock.transform.position += transform.position; _mcBlock.transform.localScale = new Vector3(1f/BlockCountX,1f/BlockCountY,1f/BlockCountZ); } } } }