# SPhotos

**成员** 6

|      |                                                 |                                                                               |
| ---- | ----------------------------------------------- | ----------------------------------------------------------------------------- |
| 函数 | [GetUploadedTexture](#getuploadedtexture)       | –                                                                             |
| 函数 | [GetSavedTexture](#getsavedtexture)             | –                                                                             |
| 函数 | [GetInventoryTextures](#getinventorytextures)   | –                                                                             |
| 函数 | [OpenUploadFileBrowser](#openuploadfilebrowser) | Opens a window that let's you select a file you wish to upload. (white-label) |
| 函数 | [OnUploadEnd](#onuploadend)                     | Binds the function c to be called when an upload operation ends.              |
| 函数 | [OnUploadStart](#onuploadstart)                 | –                                                                             |

## 函数

### GetUploadedTexture

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

返回值

`SResource`

示例

**Lua**

```lua
resourceTexture = Space.Photos.GetUploadedTexture()

```

### GetSavedTexture

void GetSavedTexture(string path, Closure onComplete)

参数

| 参数       | 类型               | 说明                                                                                         |
| ---------- | ------------------ | -------------------------------------------------------------------------------------------- |
| path       | string             |                                                                                              |
| onComplete | Closure (Callback) | Closure will be called once the saved texture has been retrieved.<br />onComplete(SResource) |

返回值

`void`

示例

**Lua**

```lua
function onComplete(SResource)
resourceTexture = SResource
end

Space.Photos.GetSavedTexture('APath', onComplete)

```

### GetInventoryTextures

Table GetInventoryTextures()

返回值

`Table`

示例

**Lua**

```lua
tableInventoryTexture = Space.Photos.GetInventoryTextures()

```

### OpenUploadFileBrowser

void OpenUploadFileBrowser()

Opens a window that let's you select a file you wish to upload. (white-label)

返回值

`void`

示例

**Lua**

```lua
Space.Photos.OpenUploadFileBrowser()

```

**Lua**

```lua
--this script will open a file upload browser when clicked
thisObject = Space.Host.ExecutingObject

function OnClickFunction()
Space.Photos.OpenUploadFileBrowser()
end


thisObject.AddClickable()
thisObject.Clickable.Tooltip = "Click me to upload photo"
thisObject.Clickable.OnClick(OnClickFunction)

```

### OnUploadEnd

void OnUploadEnd(Closure c)

**Binds the function c to be called when an upload operation ends.**

参数

| 名称 | 类型    | 默认值 |
| ---- | ------- | ------ |
| c    | Closure | –      |

返回值

`void`

示例

**Lua**

```lua
function c()
--
end

Space.Photos.OnUploadEnd(c)

```

**Lua**

```lua
--this script will show a text on screen that says "Uploading..." when a photo upload is initiated
--and will hide it when the upload has ended
thisObject = Space.Host.ExecutingObject
textObject = Space.Host.GetReference("textObject") --add a UIText object to References in Scripting Runtime
textObject.UIText.Text = "Uploading..."

function OnUploadStartFunction()
textObject.Active = true
end

function OnUploadEndFunction()
textObject.Active = false
end

Space.Photos.OnUploadStart(OnUploadStartFunction)
Space.Photos.OnUploadEnd(OnUploadEndFunction)

```

### OnUploadStart

void OnUploadStart(Closure c)

参数

| 名称 | 类型    | 默认值 |
| ---- | ------- | ------ |
| c    | Closure | –      |

返回值

`void`

示例

**Lua**

```lua
function c()
--
end

Space.Photos.OnUploadStart(c)

```

**Lua**

```lua
--this script will show a text on screen that says "Uploading..." when a photo upload is initiated
--and will hide it when the upload has ended
thisObject = Space.Host.ExecutingObject
textObject = Space.Host.GetReference("textObject") --add a UIText object to References in Scripting Runtime
textObject.UIText.Text = "Uploading..."

function OnUploadStartFunction()
textObject.Active = true
end

function OnUploadEndFunction()
textObject.Active = false
end

Space.Photos.OnUploadStart(OnUploadStartFunction)
Space.Photos.OnUploadEnd(OnUploadEndFunction)

```
