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!");
		}
	}
}
Page last updated: 2010-12-31