Horizontal,vertical,Input_Mouse,Input_Key

鼠标获取
using UnityEngine;
using System.Collections;

public class Input_Mouse : MonoBehaviour {

	void Update()
	{
//		if (Input.GetMouseButtonDown (0)) {
//			Debug.Log ("按下了鼠标左键");
//		}
//
//		if (Input.GetMouseButtonUp (0)) {
//			Debug.Log ("抬起了鼠标左键");
//		}
//
//		if (Input.GetMouseButton (0)) {
//			Debug.Log ("按住了鼠标左键");
//		}

		Debug.Log (Input.mousePosition);
	}
}

 按键获取

using UnityEngine;
using System.Collections;

public class Input_Key : MonoBehaviour {


	void Update()
	{
		//当用户按下了空格键盘,if成立(为真)
		if (Input.GetKeyDown (KeyCode.Space)) {
			Debug.Log ("按下了空格!!!");
		}

		if (Input.GetKey (KeyCode.Space)) {
			Debug.Log ("按住了空格!!!");
		}

		if (Input.GetKeyUp (KeyCode.Space)) {
			Debug.Log ("抬起了空格!!!");
		}
	}
}

  WASD获取

using UnityEngine; using System.Collections; public class Virtual : MonoBehaviour { void Update() { float h = Input.GetAxis ("Horizontal"); float v = Input.GetAxis ("Vertical"); Debug.Log (v); } }

 

posted @ 2016-10-29 15:44  扎北强子  阅读(214)  评论(0编辑  收藏  举报