best way to select rubik cube's slice in one go

I've got this:

    var slice = Array();
var selectedCube:GameObject;

function Update () {
    if(Input.GetKeyDown(KeyCode.Space)){//triggered by MSDragCube
        selectingaSlice();
    }   
}

function selectingaSlice(){ 
    slice.Clear();
    slice.Add(selectedCube.transform);

    var hits: RaycastHit[];
    var up = selectedCube.transform.TransformDirection(Vector3.up); //kierunek od DragDirection w MSDragCube

    hits = Physics.RaycastAll (transform.position, up, 10.0);

    for(var i = 0; i< hits.Length; i++){
        var hit: RaycastHit = hits*;*
 *slice.Add(hit.transform);*
 *}*
 *for(var cube: Transform in slice) cube.renderer.material.color = Color.red;*
*}*
*```*
*<p>that should add to an array (on a side note: I don't know how to dynamically change the size of a Transform[] array, so I used Unity's one) all the objects that are going to be rotated around the central cube (in a given slice)</p>*
*<p>but this, so far, selects only one "column" of a slice. so 3 cubes out of 9.*
*I wonder, how could it be done to select the whole slice. Any ideas?</p>*
*<p>EDIT:*
*I guess, maybe making all the "selected" cubes also cast ray - for example - in the right direction...*
*The point is to make one big script. Not to make many that every little cube (in this rubik's cube) have.</p>*
*<p>EDIT 2: </p>*
*<p>but then again, when I do it:</p>*
*```*
*var slice = Array();*
*var selectedCube:GameObject;*
*function Update () {*
 *if(Input.GetKeyDown(KeyCode.Space)){//triggered by MSDragCube*
 *selectingaSlice();*
 *}* 
*}*
*function selectingaSlice(){* 
 *slice.Clear();*
 *slice.Add(selectedCube.transform);*
 *var hitsUp: RaycastHit[];*
 *var hitsRight: RaycastHit[];*
 *var up = selectedCube.transform.TransformDirection(Vector3.up); //kierunek od DragDirection w MSDragCube*
 *var right = selectedCube.transform.TransformDirection(Vector3.right); //kierunek od DragDirection w MSDragCube*
*//casts up to few cubes*
 *hitsUp = Physics.RaycastAll (selectedCube.transform.position - Vector3(0,5,0), up, 10.0);*
 *for(var i = 0; i< hits.Length; i++){*
 _var hit: RaycastHit = hitsUp*;*_
 _*slice.Add(hit.transform);*_
 _*}*_
 _*print(slice.length);*_
_*//cast right from each cube*_
 _*for(var cube: Transform in slice){*_
 _*hitsRight = Physics.RaycastAll (cube.transform.position - Vector3(5,0,0), right, 10.0);*_
 _*for(i = 0; i< hits.Length; i++){*_
 <em>_hit = hitsRight*;*_</em>
 <em>_*slice.Add(hit.transform);*_</em>
 <em>_*}*_</em>
 <em>_*}*_</em>
 <em>_*print(slice.length);*_</em>
<em>_*//colorize*_</em>
 <em>_*for(var cube: Transform in slice) cube.renderer.material.color = Color.red;*_</em>
<em>_*}*_</em>
<em>_*```*_</em>
<em>_*<p>and try to test it, unity freezes. it's not responding.*_</em>
<em>_*Do you know why?</p>*_</em>

ow yea. I got it now.

for reference:

  var slice = Array();
var selectedCube:GameObject;

function Update () {
    if(Input.GetKeyDown(KeyCode.Space)){//triggered by MSDragCube
        selectingaSlice();
    }   

}

var column = Array();

function selectingaSlice(){ 
    slice.Clear();
    column.Clear();

    //~ slice.Add(selectedCube.transform);

    var hitsUp: RaycastHit[];
    var hitsRight: RaycastHit[];
    var up = selectedCube.transform.TransformDirection(Vector3.up); //kierunek od DragDirection w MSDragCube
    var right = selectedCube.transform.TransformDirection(Vector3.right); //kierunek od DragDirection w MSDragCube

//casts up to few cubes
    hitsUp = Physics.RaycastAll (selectedCube.transform.position - Vector3(0,5,0), up, 10.0);

    for(var i = 0; i< hitsUp.Length; i++){
        var hit: RaycastHit = hitsUp*;*
 *column.Add(hit.transform);*
 *}*
 *print(slice.length);*
*//cast right from each cube*
 *for(var cube: Transform in column){*
 *hitsRight = Physics.RaycastAll (cube.transform.position - Vector3(5,0,0), right, 10.0);*
 *for(i = 0; i< hitsRight.Length; i++){*
 _hit = hitsRight*;*_
 _*slice.Add(hit.transform);*_
 _*}*_
 _*}*_
 _*print(slice.length);*_
_*//colorize*_
 _*for(var cube: Transform in slice) cube.renderer.material.color = Color.red;*_
_*}*_
_*```*_

I am selecting slices basing on “subcubes” position. A user can click a “subcube” and its position and the area where the user clicks it determines the slice position and orientation. Once the slice position and orientation is sorted out, the whole slice is being selected.
I made the whole project available at http://virtualplayground.d2.pl