Event.command 键盘Command/Windows键

var command : bool

Description描述

Is Command/Windows key held down? (Read Only)

Command/Windows键被按住了么(只读)?

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

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

using UnityEngine;
using System.Collections;

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


	}
}
// Prints Command/Windows key was pressed depending the
// platform this script is being run.
//打印Command或Windows键被按下,这个脚本,具体取决于正在运行的平台。

function OnGUI() {
	var e : Event = Event.current;
	if (e.command) {
		if(Application.platform == RuntimePlatform.OSXEditor) {
			Debug.Log("Command key was pressed");
		} else if( Application.platform == RuntimePlatform.WindowsEditor) {
			Debug.Log("Windows Key was pressed!");
		}
	}
}
最后修改:2010年12月31日 Friday 21:03

本脚本参考基于Unity 3.4.1f5

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