# SUIRaycastResult

**الأعضاء** 12

|       |                                   |                                                                   |
| ----- | --------------------------------- | ----------------------------------------------------------------- |
| دالة  | [Clear](#clear)                   | Reset all the parameters of this RaycastResult                    |
| دالة  | [ToString](#tostring)             | Converts all the properties of this UIRaycastResult into a string |
| خاصية | [Distance](#distance)             | Returns the distance of the Raycast result                        |
| خاصية | [Index](#index-1)                 | Returns the Index of the Raycast result                           |
| خاصية | [Depth](#depth)                   | Returns the Depth of the Raycast result                           |
| خاصية | [SortingLayer](#sortinglayer)     | Returns the Sorting Layer of the Raycast result                   |
| خاصية | [SortingOrder](#sortingorder)     | Returns the Sorting Order of the Raycast result                   |
| خاصية | [WorldPosition](#worldposition)   | Returns the World Position vector of the Raycast result           |
| خاصية | [WorldNormal](#worldnormal)       | Returns the World Normal vector of the Raycast result             |
| خاصية | [ScreenPosition](#screenposition) | Returns the Screen Position vector of the Raycast result          |
| خاصية | [GameObject](#gameobject)         | Returns a reference to the GameObject of the Raycast result       |
| خاصية | [IsValid](#isvalid)               | Returns whether the Raycast hit a valid UI Raycast target.        |

## الدوال

### Clear

void Clear()

Reset all the parameters of this RaycastResult

القيم المرجعة

`void`

مثال

**Lua**

```lua
Result = Space.UI.Raycast()
Result.Clear()

```

### ToString

string ToString()

Converts all the properties of this UIRaycastResult into a string

القيم المرجعة

`string`

مثال

**Lua**

```lua
Result = Space.UI.Raycast().ToString()

```

**Lua**

```lua
--This script will update a UIText element with the result of a UIRaycast whenever...
--the player clicks on a Sinespace UI element
thisObject = Space.Host.ExecutingObject
uiText = Space.Host.GetReference("text").UIText --Add this object with UIText component as reference in Scripting Runtime



OnUpdate = function()

  if Space.Input.GetMouseDown(0) == true then
  result = Space.UI.Raycast()	
    if result.IsValid then 
      uiText = result.ToString()
    end
  end
end


thisObject.OnUpdate(OnUpdate)

```

## الخصائص

### Distance

float Distance {get; }

Returns the distance of the Raycast result

مثال

**Lua**

```lua
Result = Distance = Space.UI.Raycast().Distance

```

**Lua**

```lua
--This script will update a UIText element with the Distance of the UIRaycast whenever
--the player clicks on a Sinespace UI element
thisObject = Space.Host.ExecutingObject
uiText = Space.Host.GetReference("text").UIText --Add this object with UIText component as reference in Scripting Runtime


OnUpdate = function()
  if Space.Input.GetMouseDown(0) == true then
  result = Space.UI.Raycast()	
    if result.IsValid then 
      uiText = result.Distance
    end
  end
end

thisObject.OnUpdate(OnUpdate)

```

### Index

float Index {get; }

Returns the Index of the Raycast result

مثال

**Lua**

```lua
Index= Space.UI.Raycast().Index

```

**Lua**

```lua
--This script will update a UIText element with the Index of the UIRaycast whenever
--the player clicks on a Sinespace UI element
thisObject = Space.Host.ExecutingObject
uiText = Space.Host.GetReference("text").UIText --Add this object with UIText component as reference in Scripting Runtime


OnUpdate = function()
  if Space.Input.GetMouseDown(0) == true then
  result = Space.UI.Raycast()	
    if result.IsValid then 
      uiText = result.Index
    end
  end
end

thisObject.OnUpdate(OnUpdate)

```

### Depth

int Depth {get; }

Returns the Depth of the Raycast result

مثال

**Lua**

```lua
Depth= Space.UI.Raycast().Depth

```

**Lua**

```lua
--This script will update a UIText element with the Depth of the UIRaycast whenever
--the player clicks on a Sinespace UI element
thisObject = Space.Host.ExecutingObject
uiText = Space.Host.GetReference("text").UIText --Add this object with UIText component as reference in Scripting Runtime


OnUpdate = function()
  if Space.Input.GetMouseDown(0) == true then
  result = Space.UI.Raycast()	
    if result.IsValid then 
      uiText = result.Depth
    end
  end
end

thisObject.OnUpdate(OnUpdate)

```

### SortingLayer

int SortingLayer {get; }

Returns the Sorting Layer of the Raycast result

مثال

**Lua**

```lua
SortingLayer= Space.UI.Raycast().SortingLayer

```

**Lua**

```lua
--This script will update a UIText element with the Sorting Layer of the UIRaycast whenever
--the player clicks on a Sinespace UI element
thisObject = Space.Host.ExecutingObject
uiText = Space.Host.GetReference("text").UIText --Add this object with UIText component as reference in Scripting Runtime


OnUpdate = function()
  if Space.Input.GetMouseDown(0) == true then
  result = Space.UI.Raycast()	
    if result.IsValid then 
      uiText = result.SortingLayer
    end
  end
end

thisObject.OnUpdate(OnUpdate)

```

### SortingOrder

int SortingOrder {get; }

Returns the Sorting Order of the Raycast result

مثال

**Lua**

```lua
SortingOrder= Space.UI.Raycast().SortingOrder

```

**Lua**

```lua
--This script will update a UIText element with the Sorting Order of the UIRaycast whenever
--the player clicks on a Sinespace UI element
thisObject = Space.Host.ExecutingObject
uiText = Space.Host.GetReference("text").UIText --Add this object with UIText component as reference in Scripting Runtime


OnUpdate = function()
  if Space.Input.GetMouseDown(0) == true then
  result = Space.UI.Raycast()	
    if result.IsValid then 
      uiText = result.SortingOrder
    end
  end
end

thisObject.OnUpdate(OnUpdate)

```

### WorldPosition

[SVector](/docs/ar/scripting/client-scripting-api-reference/types/svector.md) WorldPosition {get; }

Returns the World Position vector of the Raycast result

مثال

**Lua**

```lua
WorldPosition= Space.UI.Raycast().WorldPosition

```

**Lua**

```lua
--This script will update a UIText element with the World Position of the UIRaycast whenever
--the player clicks on a Sinespace UI element
thisObject = Space.Host.ExecutingObject
uiText = Space.Host.GetReference("text").UIText --Add this object with UIText component as reference in Scripting Runtime


OnUpdate = function()
  if Space.Input.GetMouseDown(0) == true then
  result = Space.UI.Raycast()	
    if result.IsValid then 
      uiText = result.WorldPosition
    end
  end
end

thisObject.OnUpdate(OnUpdate)

```

### WorldNormal

[SVector](/docs/ar/scripting/client-scripting-api-reference/types/svector.md) WorldNormal {get; }

Returns the World Normal vector of the Raycast result

مثال

**Lua**

```lua
WorldNormal= Space.UI.Raycast().WorldNormal

```

**Lua**

```lua
--This script will update a UIText element with the World Normal of the UIRaycast whenever
--the player clicks on a Sinespace UI element
thisObject = Space.Host.ExecutingObject
uiText = Space.Host.GetReference("text").UIText --Add this object with UIText component as reference in Scripting Runtime


OnUpdate = function()
  if Space.Input.GetMouseDown(0) == true then
  result = Space.UI.Raycast()	
    if result.IsValid then 
      uiText = result.WorldNormal
    end
  end
end

thisObject.OnUpdate(OnUpdate)

```

### ScreenPosition

[SVector](/docs/ar/scripting/client-scripting-api-reference/types/svector.md) ScreenPosition {get; }

Returns the Screen Position vector of the Raycast result

مثال

**Lua**

```lua
ScreenPosition= Space.UI.Raycast().ScreenPosition

```

**Lua**

```lua
--This script will update a UIText element with the Screen Position of the UIRaycast whenever
--the player clicks on a Sinespace UI element
thisObject = Space.Host.ExecutingObject
uiText = Space.Host.GetReference("text").UIText --Add this object with UIText component as reference in Scripting Runtime


OnUpdate = function()
  if Space.Input.GetMouseDown(0) == true then
  result = Space.UI.Raycast()	
    if result.IsValid then 
      uiText = result.ScreenPosition
    end
  end
end

thisObject.OnUpdate(OnUpdate)

```

### GameObject

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

Returns a reference to the GameObject of the Raycast result

مثال

**Lua**

```lua
GameObject= Space.UI.Raycast().GameObject

```

**Lua**

```lua
--This script will update a UIText element with the name of the UIRaycast 
--by accesing it's GameObject whenever the player clicks on a Sinespace UI element
thisObject = Space.Host.ExecutingObject
uiText = Space.Host.GetReference("text").UIText --Add this object with UIText component as reference in Scripting Runtime


OnUpdate = function()
  if Space.Input.GetMouseDown(0) == true then
  result = Space.UI.Raycast()	
    if result.IsValid then 
      uiText = result.GameObject.Name
    end
  end
end

thisObject.OnUpdate(OnUpdate)

```

### IsValid

bool IsValid {get; }

Returns whether the Raycast hit a valid UI Raycast target. This will be true if the Raycast hits an element on Sinespace's UI

مثال

**Lua**

```lua
IsValid= Space.UI.Raycast().IsValid

```

**Lua**

```lua
--This script will check if Raycast result is valid
--and update a UIText element with the result of a UIRaycast whenever
--the player clicks on a Sinespace UI element
thisObject = Space.Host.ExecutingObject
uiText = Space.Host.GetReference("text").UIText --Add this object with UIText component as reference in Scripting Runtime



OnUpdate = function()

  if Space.Input.GetMouseDown(0) == true then
  result = Space.UI.Raycast()	
    if result.IsValid then 
      uiText = result.ToString()
    end
  end
end


thisObject.OnUpdate(OnUpdate)

```
