Unity 2d - script - detailed explanation of basic script (1) - user input event

1. Obtain user input events:

1. Monitor keyboard keys

if (Input.GetKey(KeyCode.W)){
Debug.Log("用户按下了W");
}

2. Monitor mouse buttons

if (Input.GetMouseButton(0)){
//0为左键,1为右键
Debug.Log("用户按下了鼠标左键");
}

 

Guess you like

Origin blog.csdn.net/wswdxs/article/details/106349419