> For the complete documentation index, see [llms.txt](https://docs.decentraland.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.decentraland.org/creator/content-creator-zh/chang-jing-sdk7/jiao-hu-xing/external-links.md). Agents can also search and read this documentation through its [MCP server](https://docs.decentraland.org/~gitbook/mcp).

# 外部链接

链接到其他场景或外部网站

你可以从场景添加指向其他内容的链接，包括其他场景或外部网站。

## 在 Creator Hub 中使用场景编辑器

添加外部链接或传送的最简单方法是使用场景编辑器。使用 **传送** [智能物品](https://docs.decentraland.org/creator/content-creator-zh/chang-jing-bian-ji-qi/jiao-hu-xing/smart-items.md) ，即可添加传送到 Genesis City 中其他场景的功能；也可以使用任意 **社交链接** 智能物品添加指向外部网站的链接。

![](https://2460066822-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoPnXBby9S6MrsW83Y9qZ%2Fuploads%2Fgit-blob-0b3c5ce7dcf74af234c0d02b6adccbd2d401e2f6%2Fsocial-links.webp?alt=media)

## 传送点

若要将玩家传送到其他场景，请调用以下函数，并指定要将玩家传送到的坐标。

```ts
import { teleportTo } from "~system/RestrictedActions"

(...)

teleportTo({ worldCoordinates: { x: -51, y: 1 } })
```

传送前，玩家会看到一个确认界面。该界面会显示目标场景的 `scene.json file`中的信息，包括场景的 `name`, `description` 和 `navmapThumbnail`。请参阅 [场景元数据](https://docs.decentraland.org/creator/content-creator-zh/chang-jing-sdk7/xiang-mu-lei-xing/scene-metadata.md) ，了解如何设置这些数据。

请注意，传送会将玩家带到指定坐标所在的场景，但不一定会将玩家送到该场景中的相同坐标。这意味着，前往包含多个地块的场景时，玩家可能不会落在指定的坐标上，而是会出现在场景创建者设置的某个出生点。

若要将玩家移动到当前场景中的另一组坐标，请改用 `movePlayerTo()` 函数。请参阅 [移动玩家](https://docs.decentraland.org/creator/content-creator-zh/chang-jing-sdk7/jiao-hu-xing/tou-xiang/move-player.md).

## 传送到 WORLD

若要将玩家送到未发布在 Genesis City 开放地图上的场景，而是送到独立的 [Decentraland WORLD](https://docs.decentraland.org/creator/content-creator-zh/chang-jing-sdk7/fa-bu/publishing-options.md#decentraland-worlds)，请将 `realm` 传递给 `teleportTo()`.

```ts
import { teleportTo } from "~system/RestrictedActions"

(...)

teleportTo({ realm: 'mannakia.dcl.eth' })
```

`realm` 可以接受世界名称（例如 `mannakia.dcl.eth`）或 realm URL。

如果不指定 `worldCoordinates`，玩家会落在目标世界的某个出生点。添加坐标即可指定该世界中的某个地块：

```ts
// 降落在特定世界的地块 12,34
teleportTo({
	realm: 'mannakia.dcl.eth',
	worldCoordinates: { x: 12, y: 34 },
})
```

玩家切换 realm 前会看到一个确认界面。界面会询问 *“确定要进入此 World 吗？”* 并显示目标位置（世界名称，或 realm URL 的主机名）。只有玩家确认后才会移动。

若要将玩家从某个世界送回 Genesis City，请不要包含 `realm` 字段，默认值为 Genesis City。

{% hint style="warning" %}
**📔 注意**： `realm` 字段需要 `@dcl/sdk` 7.28.0 或更高版本。
{% endhint %}

### changeRealm 已弃用

较早的场景使用 `changeRealm()` 前往某个世界。它仍然有效，但请改用 `teleportTo({ realm })` 。 `changeRealm()` 还会显示确认界面；其可选的 `message` 字段只会替换默认提示文本。

`changeRealm()` 会在玩家接受提示后立即完成，而不是等到新 realm 真正生效后才完成。在它之后立即调用 `teleportTo()` 会作用于 **旧** realm，并将玩家传送到错误的位置。 `teleportTo({ realm })` 会在一次调用中完成这两个步骤，因此不会出现这个间隙。

## 外部链接

若要添加指向外部网站的链接，请使用 `openExternalUrl()` 命令。

```ts
import { openExternalUrl } from '~system/RestrictedActions'

openExternalUrl({ url: 'google.com' })
```

为防止有人滥用此功能向玩家发送垃圾信息，只有在实体上发生明确的点击或按钮事件时，才能调用 `openExternalUrl` 。不能因计时器、碰撞区域或全局点击事件而调用此函数。有关如何操作的详细信息，请参阅 [按钮事件](https://docs.decentraland.org/creator/content-creator-zh/chang-jing-sdk7/jiao-hu-xing/an-niu-shi-jian/click-events.md) 。

调用 `openExternalUrl` 时，玩家会看到确认界面，其中会告知链接将把他们带到哪里，并可选择接受或拒绝访问该链接。

链接会在新标签页中打开，Decentraland 的原始标签页仍会保留。

如果玩家勾选 *信任此域名* 复选框，在当前会话期间，只要链接来自同一个场景且指向同一个域名，就不会再次显示提示。

## 打开 Explorer UI 面板

除了外部网站，场景还可以使用受限操作 `openExplorerUi()` 打开 Explorer 自带的面板，例如地图、设置或背包。调用必须直接响应玩家的点击或按键操作，而且对有效操作的判定规则与上文不同。请参阅 [打开 Explorer 面板](https://docs.decentraland.org/creator/content-creator-zh/chang-jing-sdk7/jiao-hu-xing/event-listeners.md#open-explorer-panels) 查看完整参考，其中包括哪些操作算作玩家操作，以及如何等待玩家关闭面板。

## 复制到剪贴板

若要将字符串复制到玩家的剪贴板，请使用 `copyToClipboard()`。此后，当玩家执行 *粘贴* 操作时，无论是在 Decentraland 聊天中，还是在其设备上的任何其他应用中，粘贴的都会是你的字符串。

```ts
import { copyToClipboard } from "~system/RestrictedActions"

copyToClipboard( { text: 'My text to copy' } )
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.decentraland.org/creator/content-creator-zh/chang-jing-sdk7/jiao-hu-xing/external-links.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
