1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
| public class cubetest : MonoBehaviour { // Start is called before the first frame update void Start() { Debug.Log("测试键盘控制"); }
// Update is called once per frame void Update() { if (Input.GetKeyDown(KeyCode.D)) { this.transform.Translate(Vector3.right * 1); } else if (Input.GetKeyDown(KeyCode.A)) { this.transform.Translate(Vector3.left * 1); } else if (Input.GetKeyDown(KeyCode.S)) { this.transform.Translate(Vector3.down * 1); } else if (Input.GetKeyDown(KeyCode.W)) { this.transform.Translate(Vector3.up * 1); }
} }
|