Hi,
just a map, so that it's easier to understand my explanations:
1 2 3
4 5 6
7 8 9
in this particular case, I would try the following:
everytime the user click on a cube, you check that cube, this is your starting point.
1: check around that cube, if it doesn't find a similar cube, forget the winning check
2: if it did find similar adjacent cubes, check the opposite direction of them adjacent cubes, if you find a similar cube on the opposite, you have a winning combination. If you are on 4 and 1 is identical, you want to check 7
3: number 2 is not enough, you also need to look in the same direction ahead of an adjacent cube, ( if you start on 1, and 2 is similar, you want to check 3 right away)
Now, to navigate within such arrays, can be tricky mathematically. You might find easier to reference your cubes using xy references:
11 21 31
12 22 32
13 23 33
this way if you are on 22 and wants to check the item below, you stay want to go on item 2(y+1). Much easier to navigate like that. So each of your gameObject should have their indexes in a variables, say "row" and "column" for example, for the center cube would have row:2 column:2
bye,
Jean