---
title: 截图
slug: world-sdk-guide-ch/gJ6SvwIXLhQ7SNS7Oc2IF
docTags: 
createdAt: 2024-09-02T08:34:13.135Z
---

## 使用截图功能

您可以使用ZepetoWorldContent API的图像相关功能在世界中保存或分享图像，并将图像发布到动态中。

ZepetoWorldContent API提供以下图像相关功能。

| **API**                                                                                                   | **描述**                                            |
| --------------------------------------------------------------------------------------------------------- | ------------------------------------------------- |
| ZepetoWorldContent.SaveToCameraRoll(rt: UnityEngine.RenderTexture, result: System.Action$1)               | 将图像保存到照片库。                                        |
| ZepetoWorldContent.SaveToCameraRoll(texture: UnityEngine.Texture2D, result: System.Action$1)              | 将图像保存到照片库。                                        |
| ZepetoWorldContent.Share(rt: UnityEngine.RenderTexture, result: System.Action$1)                          | 将图像分享至外部应用。                                       |
| ZepetoWorldContent.Share(texture: UnityEngine.Texture2D, result: System.Action$1)                         | 将图像分享至外部应用。                                       |
| ZepetoWorldContent.CreateFeed(rt: UnityEngine.RenderTexture, contents: string, result: System.Action$1)   | 将图像上传到动态。可以通过第二个参数contents指定帖子内容。世界标签会自动应用并发布到动态。 |
| ZepetoWorldContent.CreateFeed(texture: UnityEngine.Texture2D, contents: string, $result: System.Action$1) | 将图像上传到动态。可以通过第二个参数contents指定帖子内容。世界标签会自动应用并发布到动态。 |



以下是调用 ZepetoWorldContent 中图像功能的示例。

```typescript
ZepetoWorldContent.SaveToCameraRoll(this.renderTexture, (result: boolean) => {console.log(`保存结果 : ${result}`)});
ZepetoWorldContent.SaveToCameraRoll(this.texture2D, (result: boolean) => {console.log(`保存结果 : ${result}`)});

ZepetoWorldContent.Share(this.renderTexture, (result: boolean) => {console.log(`分享结果 : ${result}`)});
ZepetoWorldContent.Share(this.texture2D, (result: boolean) => {console.log(`分享结果 : ${result}`)});

ZepetoWorldContent.CreateFeed(this.renderTexture, "[内容]", (result: boolean) => {console.log(`创建动态结果 : ${result}`)});
ZepetoWorldContent.CreateFeed(this.texture2D, "[内容]", (result: boolean) => {console.log(`创建动态结果 : ${result}`)});
```



以下是使用 ZepetoWorldContent 中截图模式功能的示例代码，使用 RenderTexture。

```typescript
import { Camera, RenderTexture } from 'UnityEngine';
import { Button, Text } from 'UnityEngine.UI';
import { SpawnInfo, ZepetoPlayers } from 'ZEPETO.Character.Controller';
import { ZepetoScriptBehaviour } from 'ZEPETO.Script';
import { WorldService, ZepetoWorldContent } from 'ZEPETO.World';

export default class ZepetoWorldContentExample extends ZepetoScriptBehaviour {

    // ZepetoWorldContent 截图 UI
    public cameraRenderButton: Button;
    public saveToCameraRollButton: Button;
    public shareButton: Button;
    public createFeedButton: Button;
    public logText: Text;

    // 渲染相机
    private camera: Camera;

    // 渲染纹理
    public renderTexture: RenderTexture;

    Start() {
        ZepetoPlayers.instance.CreatePlayerWithUserId(WorldService.userId, new SpawnInfo(), true);
        ZepetoPlayers.instance.OnAddedLocalPlayer.AddListener(() => {
            this.camera = ZepetoPlayers.instance.LocalPlayer.zepetoCamera.camera;
        });

        this.cameraRenderButton.onClick.AddListener(() => {
            this.camera.targetTexture = this.renderTexture;
            this.camera.Render();
            this.camera.targetTexture = null;
        });

        this.saveToCameraRollButton.onClick.AddListener(() => {
            ZepetoWorldContent.SaveToCameraRoll(this.renderTexture, (result: boolean) => {
                this.logText.text = `保存结果 : ${result}`;
            });
        });

        this.shareButton.onClick.AddListener(() => {
            ZepetoWorldContent.Share(this.renderTexture, (result: boolean) => {
                this.logText.text = `分享结果 : ${result}`;
            });
        });

        this.createFeedButton.onClick.AddListener(() => {
            ZepetoWorldContent.CreateFeed(this.renderTexture, "[内容]", (result: boolean) => {
                this.logText.text = `创建动态结果 : ${result}`;
            });
        });
    }
}
```

:::hint{type="danger"}
- 无法在Unity编辑器模式下检查，但可以在应用程序运行时检查。
:::



## 截图&#x20;

截图模块包含在Buildit Unity Plug-in中，可以在下面的GitHub中查看模块脚本。

:::hint{type="info"}
📘 **Build it Unity Plug-in 截图模块**

- [GitHub 链接](https://github.com/Zepeto-TechEvangelist/zepeto_buildit_template/tree/main/Assets/BuilditTemplate/Modules/Screenshot)
:::

### 截图功能的使用方法

![](https://api.archbee.com/api/optimize/xv-TGeWVTX2GDZMFGOf1Y/jT8RlnrfDfZKUG57AzbQE_image.png)

截图功能可通过点击位于Buildit Unity Plug-in World Play画面右侧的相机图标来使用。

![](https://api.archbee.com/api/optimize/xv-TGeWVTX2GDZMFGOf1Y/_P-YjWdx527Rn8LhoRXET_image.png)

- **1：自拍模式按钮**
  - 可将相机切换为自拍模式。
- **2： 拍照按钮**
  - 我们可以拍摄播放画面。
- **3：视频录制按钮**
  - 我们可以录制播放画面。
- **4：退出按钮**
  - 你可以退出截图模式。

:::hint{type="info"}
✏️ **笔记本**

- 聊天对话框无法拍摄，请参考。
:::



### 摄影

![](https://api.archbee.com/api/optimize/xv-TGeWVTX2GDZMFGOf1Y/dwtOhNPliRcEJb0Ou-Hj8_image.png)

点击拍照按钮，会出现上述弹窗。 按下**Upload**按钮，拍摄的照片就会立即上传到我的Zepeto帖子中。

- 照片与截图Prefab中设置的基本Description文本一起上传到种子中。 如何更改默认文本请参阅[如何更改截图 Description 文本](docId\:Q9LRTXLLRYVeXDzA-kQap)指南。



点击**Edit**按钮可以在上传截图到种子之前修改帖子文本。

![](https://api.archbee.com/api/optimize/xv-TGeWVTX2GDZMFGOf1Y/xMYxV3oyzx9EOXVhFASy5_image.png)

- **1:共享按钮**
  - 我们可以分享截图。
- **2:下载按钮**
  - 你可以把截图保存到我的机器里。
- **3:退出按钮**
  - 你可以退出Edit模式。
- **4: 照片预览窗口**
  - 可以预览拍摄的截图。
- **5:修改后文本**
  - 你可以结合截图修改要上传到Zepeto种子上的文本。
- **6: 上传按钮**
  - 你可以把截图和文本上传到Zepeto种子。



### 视频录像

![](https://api.archbee.com/api/optimize/xv-TGeWVTX2GDZMFGOf1Y/VYv4-316Iui5uCYuLf6OX_videorecording.gif)

点击视频录制按钮即可开始录制，并显示录制时间。



### 自拍模式

![](https://api.archbee.com/api/optimize/xv-TGeWVTX2GDZMFGOf1Y/oNkb24lRswQuh3syXeJbX_image.png)

点击截图图标后，会出现自拍模式图标。




![](https://api.archbee.com/api/optimize/xv-TGeWVTX2GDZMFGOf1Y/DK1ayOa9c0YMCf9XvqV8Y_image.png)

点击该图标即可启用自拍模式。



![](https://api.archbee.com/api/optimize/xv-TGeWVTX2GDZMFGOf1Y/UF_3BUBY0CUVjYaXXeale_selfiemode.gif)

在自拍模式下，角色会看向镜头。如果相机移动超过一定角度，角色会重新面向正前方。

在自拍模式激活状态下，您可以拍照或录制视频。

再次点击自拍模式图标可退出该模式，退出截图功能时自拍模式也会一并关闭。



### 如何更改截图 Description 文本

通过弹窗的**Upload**按钮上传帖子,截图将与基本文本"**#ZEPETO World #ZEPETO #Bildy #World**"一起上传。

![](https://api.archbee.com/api/optimize/xv-TGeWVTX2GDZMFGOf1Y/sIjDFSFTg4yk5uRre_Jib_image.png)

按下**Edit**按钮时出现的**Description**盒中的文本也是基本文本"#ZEPETO World #ZEPETO #Bildy #World"。

![](https://api.archbee.com/api/optimize/xv-TGeWVTX2GDZMFGOf1Y/sxuyTGnfV1c54e3Luy9q1_image.png)

如何更改默认的Description文本如下。

::::WorkflowBlock
:::WorkflowBlockItem
在左侧 **Hierarchy** 窗口中选择 **Managers > ScreenShot**。

::Image[]{src="https://api.archbee.com/api/optimize/xv-TGeWVTX2GDZMFGOf1Y/3DInnxVAhJovobrAnddHH_image.png" size="56" width="775" height="834" position="center" showCaption="false"}
:::

:::WorkflowBlockItem
在右侧的**Inspector**窗口中，按下Prefab区域下面的**Open**按钮，打开ScreenShot Prefab。

::Image[]{src="https://api.archbee.com/api/optimize/xv-TGeWVTX2GDZMFGOf1Y/SbVI4skTHoh0W_DzrrVuC_image.png" size="58" width="775" height="954" position="center" showCaption="false"}
:::

:::WorkflowBlockItem
在左侧 **Hierarchy** 窗口中选择 **ScreenShot > SafeArea > ScreenShot > PreviewPanel > PreviewTextFieldPanel > PreviewInputField**。

::Image[]{src="https://api.archbee.com/api/optimize/xv-TGeWVTX2GDZMFGOf1Y/Ib0Eb7FFjRNuhxHU7DuBO_image.png" size="56" width="775" height="1156" position="center" showCaption="false"}
:::

:::WorkflowBlockItem
在右侧的**Inspector**窗口中查找**Text**字段，并将其更改为所需的文本。

::Image[]{src="https://api.archbee.com/api/optimize/xv-TGeWVTX2GDZMFGOf1Y/rUvD-ckD5HzBU6mGixlAw_image.png" size="56" width="777" height="769" position="center" showCaption="false"}
:::
::::

通过如下示例更改文本，可以检查 Description 盒中的文本已被更改。

::Image[]{src="https://api.archbee.com/api/optimize/xv-TGeWVTX2GDZMFGOf1Y/BhuqM4jVZYsP2fWdid8vy_group-10.png" size="52" width="775" height="767" position="center" showCaption="false"}

![](https://api.archbee.com/api/optimize/xv-TGeWVTX2GDZMFGOf1Y/8gaZrUOCSFzqwUC3rVe-H_image.png)



### 看不到截图图标时

![](https://api.archbee.com/api/optimize/xv-TGeWVTX2GDZMFGOf1Y/JGyQL9HpFb7Ew2_X0Lu1R_image.png)

如上所述，在播放画面右侧看不到截图图标时，解决方法如下。

::::WorkflowBlock
:::WorkflowBlockItem
在左侧 **Hierarchy** 窗口中选择 **Managers > ScreenShot**。

::Image[]{src="https://api.archbee.com/api/optimize/xv-TGeWVTX2GDZMFGOf1Y/zK7O2YKIa_ghgJxjkAaik_image.png" size="56" width="775" height="834" position="center" showCaption="false"}
:::

:::WorkflowBlockItem
在右侧的 **Inspector** 窗口中检查左侧的复选框。

::Image[]{src="https://api.archbee.com/api/optimize/xv-TGeWVTX2GDZMFGOf1Y/-GClHzGBnUkcFswNNSepQ_image.png" size="50" width="785" height="767" position="center" showCaption="false"}
:::
::::

