how to detect mouse click on a child object

For some reasons, I made an empty GameObject and add a child in script.
The child has a javascript for detecting itself by mouse click. (using this code -

if (Physics.Raycast(ray, hit, Mathf.Infinity)) {
    hit.transform.SendMessage("function", SendMessageOptions.DontRequireReceiver);
}

But the child is is not detected because it is under the parent which is the empty gameobject, I guess,

Anyone knows how to detect Mouse Click on the object ? Detecting either parent or child is fine.
Please help me. I am new to Unity.

Try using a new instance of the child object, and assigning that instance as the child instead of the prefab itself. Then, define child as the “clone”. Just try this:

#pragma strict

var hit : RaycastHit;
var ray : Ray;
private var parent : GameObject;
private var child : GameObject;

function Awake()
{
	parent = new GameObject("StarParent");
	child = Resources.Load("Prefabs/star") as GameObject;
	var childClone : GameObject = Instantiate(child, transform.position, Quaternion.identity);
	childClone.transform.parent = parent.transform;
	child = childClone;
}

function Update()
{
	ray = Camera.main.ScreenPointToRay(Input.mousePosition);
	if(Physics.Raycast(ray, hit, Mathf.Infinity) && Input.GetMouseButtonDown(0))
	{
		if(hit.collider == child.collider)
		{
			print ("HIT!");	
		}
	}
}