Event.character 按键字符

var character : char

Description描述

The character typed.

字符类型;就是被键盘键入的对应的字符。

Used in EventType.KeyDown event. Note that EventType.KeyUp events might not contain a character, only Event.keyCode.

EventType.KeyDown事件中使用。请注意EventType.KeyUp事件可能不包含字符,只有Event.keyCode包含。

参见:Event.keyCode.

using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
	void OnGUI() {
		Event e = Event.current;
		if (e.isKey)
			Debug.Log("Detected character: " + e.character);

	}
}
function OnGUI() {
	var e : Event = Event.current;
	if (e.isKey) {
		Debug.Log("Detected character: " + e.character);
	}
}
Page last updated: 2010-12-31