# SUIToggle

**الأعضاء** 10

|       |                                       |                                                                      |
| ----- | ------------------------------------- | -------------------------------------------------------------------- |
| دالة  | [OnValueChanged](#onvaluechanged)     | Binds a function to be triggered when value of the UIToggle changes. |
| خاصية | [Enabled](#enabled)                   | Whether the UIToggle is Enabled                                      |
| خاصية | [Interactable](#interactable)         | Whether the UIToggle is Interactable                                 |
| خاصية | [IsOn](#ison)                         | Whether the UIToggle is toggled On                                   |
| خاصية | [NormalColor](#normalcolor)           | The normal color.                                                    |
| خاصية | [HighlightedColor](#highlightedcolor) | The color of the control when it is highlighted.                     |
| خاصية | [PressedColor](#pressedcolor)         | The color of the control when it is pressed.                         |
| خاصية | [DisabledColor](#disabledcolor)       | The color of the control when it is disabled.                        |
| خاصية | [ColorMultiplier](#colormultiplier)   | This multiplies the tint color for each transition by its value.     |
| خاصية | [GameObject](#gameobject)             | –                                                                    |

## الدوال

### OnValueChanged

void OnValueChanged(Closure callback)

Binds a function to be triggered when value of the UIToggle changes.

المعاملات

| الاسم    | النوع   | القيمة الافتراضية |
| -------- | ------- | ----------------- |
| callback | Closure | –                 |

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

`void`

مثال

**Lua**

```lua
function ovc()
--
end
Space.Host.ExecutingObject.UIToggle.OnValueChanged(ovc)

```

**Lua**

```lua
--This script will make a UI Toggle show/hide the Notification Button
--[You need to add an object with UI Toggle as a reference (scripting runtime)]

toggle = Space.Host.GetReference("Toggle").UIToggle


OnValueChanged = function()
  if toggle.IsOn then
    Space.UI.ShowNotificationButton= true
  else
    Space.UI.ShowNotificationButton= false
  end
end

toggle.OnValueChanged(OnValueChanged)

```

## الخصائص

### Enabled

bool Enabled {get; set; }

Whether the UIToggle is Enabled

مثال

**Lua**

```lua
Space.Host.ExecutingObject.UIToggle.Enabled = true

```

**Lua**

```lua
--clicking this object will toggle a Toggles's Enabled status

thisGameObject = Space.Host.ExecutingObject
toggle = Space.Host.GetReference("toggle").UIToggle 
--make sure to add this reference to the Scripting Runtime component


OnClick = function()
toggle.Enabled =  not toggle.Enabled
end


thisGameObject.AddClickable()
thisGameObject.Clickable.OnClick(OnClick)

```

### Interactable

bool Interactable {get; set; }

Whether the UIToggle is Interactable

مثال

**Lua**

```lua
Space.Host.ExecutingObject.UIToggle.Interactable = true

```

**Lua**

```lua
--clicking this object will toggle a Toggles's Interactable status

thisGameObject = Space.Host.ExecutingObject
toggle = Space.Host.GetReference("toggle").UIToggle 
--make sure to add this reference to the Scripting Runtime component


OnClick = function()
toggle.Interactable=  not toggle.Interactable
end


thisGameObject.AddClickable()
thisGameObject.Clickable.OnClick(OnClick)

```

### IsOn

bool IsOn {get; set; }

Whether the UIToggle is toggled On

مثال

**Lua**

```lua
Space.Host.ExecutingObject.UIToggle.IsOn = true

```

**Lua**

```lua
--This script will make a UI Toggle show/hide the Notification Button
--[You need to add an object with UI Toggle as a reference (scripting runtime)]

toggle = Space.Host.GetReference("Toggle").UIToggle


OnValueChanged = function()
  if toggle.IsOn then
    Space.UI.ShowNotificationButton= true
  else
    Space.UI.ShowNotificationButton= false
  end
end

toggle.OnValueChanged(OnValueChanged)

```

### NormalColor

SColor NormalColor {get; set; }

The normal color.

مثال

**Lua**

```lua
Space.Host.ExecutingObject.UIToggle.NormalColor = Color.Red

```

### HighlightedColor

[SColor](/docs/ar/scripting/client-scripting-api-reference/types/scolor.md) HighlightedColor {get; set; }

The color of the control when it is highlighted.

مثال

**Lua**

```lua
Space.Host.ExecutingObject.UIToggle.HighlightedColor = Color.Red

```

### PressedColor

[SColor](/docs/ar/scripting/client-scripting-api-reference/types/scolor.md) PressedColor {get; set; }

The color of the control when it is pressed.

مثال

**Lua**

```lua
Space.Host.ExecutingObject.UIToggle.PressedColor = Color.Red

```

### DisabledColor

[SColor](/docs/ar/scripting/client-scripting-api-reference/types/scolor.md) DisabledColor {get; set; }

The color of the control when it is disabled.

مثال

**Lua**

```lua
Space.Host.ExecutingObject.UIToggle.DisabledColor = Color.Red

```

### ColorMultiplier

float ColorMultiplier {get; set; }

This multiplies the tint color for each transition by its value.

مثال

**Lua**

```lua
Space.Host.ExecutingObject.UIToggle.ColorMultiplier = 1.2

```

### GameObject

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

مثال

**Lua**

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

```
