# SScriptingResources

**成员** 4

|      |                             |                                                                                  |
| ---- | --------------------------- | -------------------------------------------------------------------------------- |
| 函数 | [GetResource](#getresource) | Returns the SResource with the specified name, or else returns nil if not found. |
| 属性 | [Enabled](#enabled)         | Return whether the ScriptingResources component is Enabled or not                |
| 属性 | [Resources](#resources)     | Returns an array of all resources contained within this component.               |
| 属性 | [GameObject](#gameobject)   | –                                                                                |

## 函数

### GetResource

[SResource](/docs/zh-Hans/scripting/client-scripting-api-reference/types/sresource.md) GetResource(string name)

Returns the SResource with the specified name, or else returns nil if not found.

参数

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

返回值

`SResource`

示例

**Lua**

```lua
resource = Space.Host.ExecutingObject.Resources.GetResource("ResourceName")

```

**Lua**

```lua
local thisObject=Space.Host.ExecutingObject
local thisObjectResource=thisObject.Resources.GetResource("Test")
if thisObjectResource == nil then
    Space.Log("That resource was not found.")
else
    Space.Log("That resource exists and can be used.")
end

```

## 属性

### Enabled

bool Enabled {get; set; }

Return whether the ScriptingResources component is Enabled or not

示例

**Lua**

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

```

### Resources

SResource\[] Resources {get; }

Returns an array of all resources contained within this component.

示例

**Lua**

```lua
arrayOfResources = Space.Host.ExecutingObject.Resources.Resources

```

### GameObject

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

示例

**Lua**

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

```
