> 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-ko/build-for-mobile/develop/detect-platform.md). Agents can also search and read this documentation through its [MCP server](https://docs.decentraland.org/~gitbook/mcp).

# 플랫폼 감지

씬이 모바일, 데스크톱 또는 웹에서 실행 중인지 감지합니다.

다음 `isMobile()` 함수를 사용해 모바일에 맞게 UI, 컨트롤, 게임플레이를 조정하세요. 씬 로직을 완전히 분기하지 않고도 모든 클라이언트에서 훌륭한 경험을 제공하는 권장 방법입니다.

## 사용 가능한 함수

```ts
import { getPlatform, isMobile, isDesktop, isWeb } from '@dcl/sdk/platform'
```

* **`getPlatform()`** — 현재 플랫폼을 다음 값으로 반환합니다: `'mobile' | 'desktop' | 'web' | null`. 탐색기에서 씬에 플랫폼 정보를 전달할 때까지 `null` 을 반환합니다(씬이 시작된 직후 전달됩니다).
* **`isMobile()`** — 플레이어가 모바일 클라이언트를 사용하는 경우 `true` 를 반환합니다.
* **`isDesktop()`** — 플레이어가 데스크톱 클라이언트를 사용하는 경우 `true` 를 반환합니다.
* **`isWeb()`** — 플레이어가 웹 클라이언트를 사용하는 경우 `true` 를 반환합니다.

{% hint style="warning" %}
**📔 참고**: 이 함수들은 씬이 시작될 때 비동기적으로 설정되는 값을 읽습니다. 따라서 `main()` 이 실행될 때 해당 값이 이미 준비되어 있다고 보장할 수 없습니다. 너무 일찍 호출하면 여전히 `null` / `또는`false `를 반환할 수 있습니다. 안전하게 하려면` getPlatform() `null`이

```ts
import { engine } from '@dcl/sdk/ecs'
null이 아닌 값을 반환할 때까지 플랫폼에 따라 달라지는 설정을 미루세요. 예를 들어 시스템 안에서 확인할 수 있습니다:

import { getPlatform } from '@dcl/sdk/platform'
  function platformCheckSystem() {
  if (getPlatform() === null) return
  setupUI()
}

engine.removeSystem(platformCheckSystem)
```

{% endhint %}

## 플랫폼별로 UI 분기하기

일반적인 패턴은 모바일 플레이어와 데스크톱 플레이어에 서로 다른 UI를 설정하는 것입니다:

```ts
import { isMobile, isDesktop } from '@dcl/sdk/platform'

function setupUI() {
  if (isMobile()) {
    // 터치에 적합한 더 큰 버튼과 단순한 레이아웃
    createMobileUI()
  } else if (isDesktop()) {
    // 키보드와 마우스에 맞춘 더 조밀한 레이아웃
    createDesktopUI()
  }
}
```

같은 패턴을 사용해 다음 항목도 표시하거나 숨길 수 있습니다:

* 각 입력 방식에 맞춘 화면 안내.
* 모바일에서 클릭 가능한 작은 요소를 더 큰 터치 영역으로 바꾸세요.
* 모바일에서 사용하기 어려운 입력 바인딩을 비활성화하세요(참조: [모바일 입력](https://docs.decentraland.org/creator/content-creator-ko/build-for-mobile/develop/input-on-mobile.md)).

## 원시 플랫폼 값 확인

하나의 switch 문에서 여러 플랫폼을 처리해야 한다면 다음을 사용하세요. `getPlatform()`:

```ts
null이 아닌 값을 반환할 때까지 플랫폼에 따라 달라지는 설정을 미루세요. 예를 들어 시스템 안에서 확인할 수 있습니다:

const platform = getPlatform()

switch (platform) {
  case 'mobile':
    // 모바일 전용 동작
    break
  case 'desktop':
    // 데스크톱 전용 동작
    break
  case 'web':
    // 웹 전용 동작
    break
  case null:
    // 플랫폼을 아직 알 수 없음
    break
}
```

## 관련 항목

* [모바일 안전 영역](https://docs.decentraland.org/creator/content-creator-ko/build-for-mobile/develop/safe-area.md)
* [모바일 UI 모범 사례](https://docs.decentraland.org/creator/content-creator-ko/build-for-mobile/develop/ui-best-practices.md)
* [화면 UI](https://docs.decentraland.org/creator/content-creator-ko/sdk7/2d-ui/onscreen-ui.md)


---

# 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-ko/build-for-mobile/develop/detect-platform.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.
