按下事件
void Update ()
{
if(Input.GetKeyDown(KeyCode.W))
{
Debug.Log("W");
}
if(Input.GetKeyDown(KeyCode.S))
{
Debug.Log("S");
}
if(Input.GetKeyDown(KeyCode.A))
{
Debug.Log("A");
}
if(Input.GetKeyDown(KeyCode.D))
{
Debug.Log("D");
}
if(Input.GetKeyDown(KeyCode.Space))
{
Debug.Log("Space");
}
}
抬起事件
if(Input.GetKeyUp(KeyCode.Space))
{
Debug.Log("D");
}
鼠标事件 0代表左,1代表右键,2代表中间键
if(Input.GetMouseButtonDown(0))
{
Debug.Log("left"+ Input.mousePosition);
}
if(Input.GetMouseButtonUp(1))
{
Debug.Log("Right" + Input.mousePosition);
}
if(Input.GetMouseButton(2))
{
Debug.Log("Center" + Input.mousePosition);
}