Accessing Colliders in IF statement from PARENT Object.

Hello,
This is my Javascript I made, I need to access the collider on these GameObjects to see if the mouse CLICKS on the Mesh of the Object that i have a MESH COLLIDER on.

Code:

var ButtonLeft:Collider;
var ButtonRight:Collider;
var GridCount : float = 0;

function Update () {
	GridCount = Mathf.Clamp (GridCount, 0, 3);
}

function OnMouseDownAsButton () {
	
	if (ButtonRight) {
		GridCount ++;
	}
	if (ButtonLeft) {
		GridCount --;
	}
	
	if (GridCount == 0) {
		
		if (ButtonRight) {
			//Move all level objs left one grid
			Debug.Log (GridCount);
		}
		
		if (ButtonLeft) {
			//Move all level objs right one grid
			Debug.Log (GridCount);
		}
	}
	
	if (GridCount == 1) {
		
		if (ButtonRight) {
			//Move all level objs left one grid
			Debug.Log (GridCount);
		}
		
		if (ButtonLeft) {
			//Move all level objs right one grid
			Debug.Log (GridCount);
		}
	}
	
	if (GridCount == 2) {
		
		if (ButtonRight) {
			//Move all level objs left one grid
			Debug.Log (GridCount);
		}
		
		if (ButtonLeft) {
			//Move all level objs right one grid
			Debug.Log (GridCount);
		}
	}

}

Hierarchy:

[12895-screen+shot+2013-07-07+at+8.08.59+pm.png|12895]

In the Above Picture the parent object Arrows has the above script on it.

In the above picture each Child Object has a MESH COLLIDER on it.

Now knowing that where the script is how do I access the colliders IN the IF STATEMENTS, I have

Example:

if (ButtonRight) {
		GridCount ++;
	}

Thanks for the help!
I know its a simple thing, I just cant figure it out!
Daniel

This code is wrong: OnMouseDownAsButton is a custom function, not any valid Unity event, and ButtonLeft and ButtonRight shouldn’t be Collider references (using a Collider reference in an if statement only tests whether it’s null or not).

If you really want a single script attached to Arrows, you should declare the variables as boolean and use raycast to detect whether one of the arrows was hit:

var ButtonLeft: boolean;
var ButtonRight: boolean;
var GridCount = 0;

function Update(){
  // verify if one of the arrows was clicked:
  DetectButtonClick();
  // now you have ButtonLeft or ButtonRight true if the corresponding
  // arrows were clicked - place your code here
}

function DetectButtonClick(){
  ButtonLeft = false; // assume no clicks initially
  ButtonRight = false;
  if (Input.GetMouseButtonDown(0)){ // if left button pressed...
    // create a ray passing through the mouse pointer:
    var ray: Ray = Camera.main.ScreenPointToRay(Input.mousePosition);
    var hit: RaycastHit;
    if (Physics.Raycast(ray, hit)){ // do a raycast
      if (hit.transform.name == "ArrowLeft"){ // left arrow clicked?
        ButtonLeft = true;
      } 
      else
      if (hit.transform.name == "ArrowRight"){ // right arrow clicked?
        ButtonRight = true;
      }
    }
  }
}

EDITED: GetMouseButtonDown was incorrectly written as MouseButtonDown. Answer fixed now.