# SGraphicRaycaster

**成员** 4

|      |                                             |                                                                                                                  |
| ---- | ------------------------------------------- | ---------------------------------------------------------------------------------------------------------------- |
| 函数 | [Raycast](#raycast)                         | Perform the raycast against the list of graphics associated with the Canvas and returns first UI raycast result. |
| 属性 | [SortOrderPriority](#sortorderpriority)     | Priority of the raycaster based upon render orderPriority of the raycaster based upon sort order.                |
| 属性 | [RenderOrderPriority](#renderorderpriority) | Priority of the raycaster based upon render order.                                                               |
| 属性 | [GameObject](#gameobject)                   | –                                                                                                                |

## 函数

### Raycast

[SUIRaycastResult](/docs/zh-Hans/scripting/client-scripting-api-reference/types/suiraycastresult.md) Raycast()

Perform the raycast against the list of graphics associated with the Canvas and returns first UI raycast result.

返回值

`SUIRaycastResult`

示例

**Lua**

```lua
raycastResult = Space.Host.ExecutingObject.GraphicRaycaster.Raycast()

```

**Lua**

```lua
local trans = Space.Host.ExecutingObject
local canvas = Space.Host.GetReference("Canvas")
local gr = canvas.GraphicRaycaster
function Update()
    local raycast = gr.Raycast()
    Space.Log(raycast.ToString())
end
trans.OnUpdate(Update)

```

## 属性

### SortOrderPriority

int SortOrderPriority {get; }

Priority of the raycaster based upon render orderPriority of the raycaster based upon sort order.

示例

**Lua**

```lua
Space.Host.ExecutingObject.GraphicRaycaster.SortOrderPriority= 1

```

### RenderOrderPriority

int RenderOrderPriority {get; }

Priority of the raycaster based upon render order.

示例

**Lua**

```lua
Space.Host.ExecutingObject.GraphicRaycaster.RenderOrderPriority = 1

```

### GameObject

[SGameObject](/docs/zh-Hans/scripting/client-scripting-api-reference/types/sgameobject.md) GameObject {get; }

示例

**Lua**

```lua
theGameObject = Space.Host.ExecutingObject.GraphicRaycaster.GameObject

```
