#pragma strict
var crosshairTexture : Texture2D;
private var position : Rect;
static var OriginalOn = true;
private var MiddleVector : Vector3; 
var ray: Ray; 
function Start() {	
    Screen.showCursor = false; 
}
function Update() {
    position = Rect(
	(Screen.width - crosshairTexture.width) / 2,
	(Screen.height - crosshairTexture.height) /2,
	crosshairTexture.width, 
	crosshairTexture.height);
    
    MiddleVector.x = Screen.width/2;
    MiddleVector.y = Screen.height/2;
    ray = camera.ScreenPointToRay(MiddleVector);
    var hit : RaycastHit;
    if (Input.GetMouseButtonUp(0) && Physics.Raycast(ray, hit)) {
	    if (hit.collider.name == "Cube")
		Debug.Log(hit.collider.name);
/*
	    hit.collider.SendMessage("DoRotation",  SendMessageOptions.DontRequireReceiver);
	    var animacion = hit.collider.GetComponent(Animator);
	    if (!animacion.GetBool("NextAnimation")){
		    animacion.SetBool("NextAnimation", true);
	    }
	    else{
		    animacion.SetBool("NextAnimation", false);  
	    }
*/
	    
    }
	
if (Input.GetKeyDown ("q")){
     Screen.showCursor = !Screen.showCursor;
 }
}
function OnGUI() {
        GUI.DrawTexture(position, crosshairTexture);
 
}