Rotate Array of gameobjects similar to rubix

I have an array of cubes instantiated 3x3x3, I would like to move the faces of the cubes similar to a rubix cube, however the blocks are not multi-faced, just a single cube. Code for instantiating the blocks(irrelevant but thought I would add it).
Thx in advance for any assistance.

for (int y= 0; y < gridHeight; y++) {
			for (int x= 0; x < gridWidth; x++) {
				for (int z=0; z< gridDepth; z++) {

					GameObject Block = Instantiate (PuzzleObj [Random.Range (0, PuzzleObj.Length)], new Vector3 (PuzzlePieces.transform.position.x + x * puzzleXoffset, PuzzlePieces.transform.position.y + y * puzzleYoffset, PuzzlePieces.transform.position.z + z * puzzleZoffset), Quaternion.identity) as GameObject;
					Block.transform.parent = pivotPoint.transform;




I’m making a game and one of my traps is a big rubik’s cube that rotates itself, with spikes on some of it’s cubes.
I put some big box colliders on the inside that can interact only with the cubes.
(their pivot is on the center)
Sequence goes like:

  1. Inner box collider enabled
  2. Grabs any cube that is touching the
  3. Parent them to collider
  4. Rotate collider
  5. Unparent all cubes.
  6. Wait a bit
  7. Collider 2 does the same thing

And goes on till it loops around.