# SScriptingData

**成员** 6

|      |                                 |                                         |
| ---- | ------------------------------- | --------------------------------------- |
| 函数 | [GetVariable](#getvariable)     | Return the object of the variable.      |
| 函数 | [SetVariable](#setvariable)     | Set properties to variable.             |
| 属性 | [Enabled](#enabled)             | Is the ScriptingData component Enabled? |
| 属性 | [Variables](#variables)         | –                                       |
| 属性 | [ComponentName](#componentname) | The name of this component.             |
| 属性 | [GameObject](#gameobject)       | –                                       |

## 函数

### GetVariable

object GetVariable(string name)

Return the object of the variable.

参数

| 名称 | 类型   | 默认值 |
| ---- | ------ | ------ |
| name | string | –      |

返回值

`object`

示例

**Lua**

```lua
Space.Host.ExecutingObject.Data.GetVariable("variableName")

```

### SetVariable

void SetVariable(string name, DynValue property, bool persistent = false)

Set properties to variable.

参数

| 名称       | 类型     | 默认值 |
| ---------- | -------- | ------ |
| name       | string   | –      |
| property   | DynValue | –      |
| persistent | bool     | false  |

返回值

`void`

示例

**Lua**

```lua
Space.Host.ExecutingObject.SetVariable("variableName",5,true)

```

## 属性

### Enabled

bool Enabled {get; set; }

Is the ScriptingData component Enabled?

示例

**Lua**

```lua
Space.Host.ExecutingObject.Data.Enabled = false

```

**Lua**

```lua
--clicking this object will Enable/Disable it's Scripting Data component
thisGameObject = Space.Host.ExecutingObject
component = thisGameObject.Data

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


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

```

### Variables

string\[] Variables {get; }

示例

**Lua**

```lua
variableNames = Space.Host.ExecutingObject.Data.Variables

```

### ComponentName

string ComponentName {get; }

The name of this component.

示例

**Lua**

```lua
componentName = Space.Host.ExecutingObject.Data.ComponentName

```

### GameObject

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

示例

**Lua**

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

```
