Event.alt 键盘Alt键

var alt : bool

Description描述

Is Alt/Option key held down? (Read Only)

Alt或Option键按住了么(只读)?

On Windows, this returns true if any Alt key is held down.
On Mac, this returns true if any Option key is held down.

在Windows系统,如果任意Alt键被按下,返回真;
在Mac系统,如果任意Option键被按下,返回真。

using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
	void OnGUI() {
		Event e = Event.current;
		if (e.alt)
			if (Application.platform == RuntimePlatform.OSXEditor)
				Debug.Log("Option key was pressed");
			else
				if (Application.platform == RuntimePlatform.WindowsEditor)
				Debug.Log("Alt Key was pressed!");


	}
}
// Prints Option or Alt key was pressed depending the
// platform this script is being run.
//打印Option或Alt键被按下,这个脚本,具体取决于正在运行的平台。
function OnGUI() {
	var e : Event = Event.current;
	if (e.alt) {
		if(Application.platform == RuntimePlatform.OSXEditor) {
			Debug.Log("Option key was pressed");
		} else if( Application.platform == RuntimePlatform.WindowsEditor) {
			Debug.Log("Alt Key was pressed!");
		}
	}
}
最后修改:2010年12月31日 Friday 20:32

本脚本参考基于Unity 3.4.1f5

英文部分版权属©Unity公司所有,中文部分© Unity圣典 版权所有,未经许可,严禁转载 。