GUIUtility.GetControlID 获取控件ID

static function GetControlID (focus : FocusType) : int
static function GetControlID (hint : int, focus : FocusType) : int
static function GetControlID (contents : GUIContent, focus : FocusType) : int
static function GetControlID (focus : FocusType, position : Rect) : int
static function GetControlID (hint : int, focus : FocusType, position : Rect) : int
static function GetControlID (contents : GUIContent, focus : FocusType, position : Rect) : int

Description描述

Get a unique ID for a control.

为控件获取一个唯一ID。

using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
	void OnGUI() {
		Debug.Log("Available id: " + GUIUtility.GetControlID(FocusType.Passive));
	}
}
// Prints a not used ID that can be assigned to a control
//打印一个没有使用的ID,可以被指定给一个控件
function OnGUI() {
	// Gets a ID for a control that cannot receive keyboard focus (A button)
	//为不能接收键盘焦点的控件(按钮),获取一个ID.
	Debug.Log("Available id: " + GUIUtility.GetControlID(FocusType.Passive));
}
Page last updated: 2011-1-4