当鼠标按键按下时,返回一次true,后面參数0是左键,1是右键,2是中键
if(Input.GetMouseButtonDown(0))
Debug.Log("Pressed left click.");
if(Input.GetMouseButtonDown(1))
Debug.Log("Pressed right click.");
if(Input.GetMouseButtonDown(2))
Debug.Log("Pressed middle click.");
当鼠标按键按下时,返回true,可能多次,依据你鼠标按下的时间 ,后面參数0是左键,1是右键,2是中键
if(Input.GetMouseButton(0))
Debug.Log("Pressed left click.");
if(Input.GetMouseButton(1))
Debug.Log("Pressed right click.");
if(Input.GetMouseButton(2))
Debug.Log("Pressed middle click.");
当鼠标按键按下后弹起时,返回一次true,后面參数0是左键,1是右键,2是中键
if(Input.GetMouseButtonUp(0))
Debug.Log("Pressed left click.");
if(Input.GetMouseButtonUp(1))
Debug.Log("Pressed right click.");
if(Input.GetMouseButtonUp(2))
Debug.Log("Pressed middle click.");