# SResource

## Index

### Properties Index

| Property                                            |
| --------------------------------------------------- |
| string [**Name** ](#name)`get`                      |
| string [**Type** ](#type)`get`                      |
| string [**AsText** ](#astext)`get`                  |
| SGameObject [**AsGameObject** ](#asgameobject)`get` |
| SMaterial [**AsMaterial** ](#asmaterial)`get`       |
| float [**TextureWidth** ](#texturewidth)`get`       |
| float [**TextureHeight** ](#textureheight)`get`     |

## Properties

### Name

string **Name** `get`

*Returns the name of the resource as entered in the scripting runtime*

{% tabs %}
{% tab title="Lua" %}

```lua
ResourceName = Space.Resources[1].Name
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Lua" %}

```lua
--the below script will search through the Scripting Runtime's resources
--and return the first instance of an Animation Clip
--[You need to add a few resources to the scripting runtime and make one of them an animation]


resources = Space.Resources

for i = 1, #resources do
 if resources[i].Type == "AnimationClip" then
  Space.Log("Resource #".. i .. " is an Animation Clip. The resource name is: " .. resources[i].Name)
  break
 end
  end
```

{% endtab %}
{% endtabs %}

### Type

string **Type** `get`

*Returns the type of the resource as a string*

{% tabs %}
{% tab title="Lua" %}

```lua
ResourceType = Space.GetResource("Resource Name").Type
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Lua" %}

```lua
--the below script will search through the Scripting Runtime's resources
--and return the first instance of an Animation Clip
--[You need to add a few resources to the scripting runtime and make one of them an animation]


resources = Space.Resources

for i = 1, #resources do
 if resources[i].Type == "AnimationClip" then
  Space.Log("Resource #".. i .. " is an Animation Clip. The resource name is: " .. resources[i].Name)
  break
 end
  end
```

{% endtab %}
{% endtabs %}

### AsText

string **AsText** `get`

*Converts the resource's type from SResource type to string*

{% tabs %}
{% tab title="Lua" %}

```lua
Text = Space.GetResource("Resource Name").AsText
```

{% endtab %}
{% endtabs %}

### AsGameObject

[SGameObject](https://docs.sine.space/scripting/client-scripting-api-reference/types/sgameobject) **AsGameObject** `get`

*Property Description*

{% tabs %}
{% tab title="Lua" %}

```lua
GameObject = Space.GetResource("Resource Name").AsGameObject
```

{% endtab %}
{% endtabs %}

### AsMaterial

[SMaterial](https://docs.sine.space/scripting/client-scripting-api-reference/types/smaterial) **AsMaterial** `get`

*Converts the resource's type from SResource to SMaterial*

{% tabs %}
{% tab title="Lua" %}

```lua
Material = Space.GetResource("Resource Name").AsMaterial
```

{% endtab %}
{% endtabs %}

### TextureWidth

float **TextureWidth** `get`

*Returns the Texture Width of this resource*

{% tabs %}
{% tab title="Lua" %}

```lua
TextureWidth = Space.GetResource("Resource Name").TextureWidth
```

{% endtab %}
{% endtabs %}

### TextureHeight

float **TextureHeight** `get`

*Returns the Texture Height of this resource*

{% tabs %}
{% tab title="Lua" %}

```lua
TextureHeight = Space.GetResource("Resource Name").TextureHeight
```

{% endtab %}
{% endtabs %}
