---
title: 実行時の画面の向きを変更
slug: world-sdk-guide-ja/SI17YU1MjrUu1-2EqHyV9
docTags: 
createdAt: 2024-09-02T08:34:13.135Z
---

ワールド設定でデフォルト表示される画面の向きを設定してください。

![](https://api.archbee.com/api/optimize/fCt3n1oCa8rgNJ8fw9I2N-pa_-ov_CvYaVn_DNHQzGJ-20240904-102413.png)

- 向き : 画面の向きを選択してください。
  - 縦
  - 横



以下は、実行時に画面の向きを変更するためのサンプルコードです。

サポートされている画面の向きは、縦と横の2つだけです。

:::CodeblockTabs
ChangeOrientation

```typescript
import { ZepetoScriptBehaviour } from 'ZEPETO.Script';
import { Button } from 'UnityEngine.UI';
import { Screen, ScreenOrientation } from "UnityEngine";
  
  
export default class ChangeOrientation extends ZepetoScriptBehaviour {
  
    public orientationBtn: Button;
      
  
    Start() {
  
        // ボタンがクリックされたとき
        this.orientationBtn.onClick.AddListener(() => {
             
            if(Screen.orientation == ScreenOrientation.Landscape)
            {
              	// 画面の向きを縦に設定
                Screen.orientation = ScreenOrientation.Portrait;
            }
            else
            {
              	// 画面の向きを横に設定
                Screen.orientation = ScreenOrientation.Landscape;
            } 
        });
  
    }
}
```
:::

:::hint{type="success"}
👍 **ヒント**

- デフォルトのUI（ホームボタン、チャットボタン）とV-padは、画面の向きを変更すると自動的に横縦切り替えをサポートします。
- コンテンツに他のカスタムUIを提供する場合、向きに対応する必要があります。
:::

