unity simultate mouse click code example

Example 1: how to detect a mouse click in unity

using UnityEngine;
using System.Collections;

		if (Input.GetMouseButtonDown(0)) {
        	//Left Mouse Button
        } else if (Input.GetMouseButtonDown(1)) {
        	//Right Mouse Button
        } if (Input.GetMouseButtonDown(2)) {
        	//Middle Mouse Button
        }

Example 2: unity mouse click screen

var cameraloc:Camera; 
var mousePos:Vector3; 
var worldPos:Vector3; 
cameraloc = GameObject.Find("Camera").GetComponent(Camera); 
mousePos = Input.mousePosition; 
worldPos = cameraloc.ScreenToWorldPoint(mousePos);