HOW TO DESTROY THE CUBES IN MATCH 3D GAME , IF THREE ARE IN SAME COLOUR?

Sir ,
i have used the following code to creat the cubes and randomised it …

and in the another script i have used
void OnMouseDown()
{
cube.gemPosX=transform.position.x;
destroy(this.gameObject);
}

But how do i code such that the cubes get destroy when the colours are matched

Please help me…

You could create two GameObject variables in the OnMouseDown function, one for the firstly clicked object and the other for the second object, perhaps give every gem a tag, BlueGem gets a BlueGem tag. and compare the tags.