GUILayer.HitTest 位置检测

function HitTest (screenPosition : Vector3) : GUIElement

Description描述

Get the GUI element at a specific screen position.

在特定的屏幕位置,获取GUI元素。

Returns the GUIElement at a specific point on screen. If screenPosition is inside some GUIElement, that element is returned. Returns null if the position is not inside any GUI element. GUI elements that belong to Ignore Raycast layer will be ignored, as if they would not exist.

返回屏幕上在特定点的GUIElement。如果screenPosition在GUIElement里面,则该元素被返回。如果screenPosition不在GUI元素里面,返回null。GUI元素属于忽略光线投射层将被忽略,就像他们不存在。

screenPosition is measured in screen coordinates, like the values returned by Input.mousePosition property.

screenPosition是基于屏幕坐标,例如Input.mousePosition属性返回的值。

Note: GUILayer.HitTest only finds old-school GUI components (made up of the classes GUIElement, GUITexture, GUIText, GUILayer), and will not work with the "new" one (referred to as "UnityGUI" and made up of all the other GUIAnything classes, and the OnGUI() call).
So if you're using UnityGUI, HitTest won't find anything.

注意:GUILayer.HitTest只查找老式GUI组件(由类GUIElement, GUITexture, GUIText, GUILayer组成),并不会工作在新的组件上(被称为UnityGUI和由所有其他GUI什么的类组成,和OnGUI()调用)。因此如果你使用UnityGUI,HitTest将不会找到任何东西。

参见: GUIElement.HitTest, Input.mousePosition

Page last updated: 2010-12-25