如何操作我們想要的操作東西。。。
點擊Edit--project Settings--input
看到這大家就可以自行領悟了。。。
當然還是需要代碼的。。。。。
public class InputClass : MonoBehaviour
{
public float speed = 3f;
private void Update()
{
//Input.GetKey按住
//Input.GetKeyDown按下
//Input.GetKeyUp擡起
if (Input.GetKey(KeyCode.Space))
{
Debug.Log("按住了空格鍵");
}
//左0右1中2鍵
if(Input.GetMouseButton(0))
{
Debug.Log("按住了鼠標左鍵");
}
//Debug.Log("鼠標座標:"+Input.mousePosition);
float hor = Input.GetAxis("Horizontal");
float ver = Input.GetAxis("Vertical");
//Debug.Log("Hor:" + hor);
//Debug.Log("Vert:" + ver);
//1m/s 2m/s
transform.position += new Vector3(hor, 0, ver) * Time.deltaTime * speed;
if(Input.GetButton("Fire"))
{
Debug.Log("Fire");
}
float mousex = Input.GetAxis("Mouse X");
Debug.Log("mousex" + mousex);
}
}
大家可以自行研究一下。