鼠标双击点击物体
var hit : RaycastHit;
private var ButtonClicked = false;
private var lastTime :float= 0;
private var nowTime :float = 0;
function Update ()
{
if(Input.GetMouseButtonDown(0))
{
nowTime = Time.time;
if (lastTime +0.3 > nowTime)
{
ButtonClicked = true;
}
else
{
ButtonClicked = false;
}
lastTime = nowTime;
if(ButtonClicked)
{
var ray = Camera.main.ScreenPointToRay (Input.mousePosition);
if (Physics.Raycast (ray, hit))
{
var str = hit.collider.gameObject.name;
print(str);
//do sth
}
}
}
}