---
title: デバイスシミュレーターの拡張
product: Unity Editor
version: '6000.0'
latest_version: '7000.0'
status: This page documents version 6000.0. The latest version is 7000.0.
canonical: https://docs.unity.com/ja-jp/engine/6000.0/manual/platform-specific/cross-platform-features/device-simulator/plugins
latest_url: https://docs.unity.com/ja-jp/engine/7000.0/manual/platform-specific/cross-platform-features/device-simulator/plugins.md
last_updated: 2026-10-30
generated_at: 2026-12-02T17:13:33.677Z
locale: ja-jp
---

# デバイスシミュレーターの拡張

> デバイスシミュレータープラグインを作成して、シミュレータービューの機能とユーザーインターフェースを拡張する方法を説明しています。

デバイスシミュレーターは、機能を拡張し、シミュレータービューのコントロールパネルの UI を変更するプラグインをサポートしています。

## プラグインの作成##creating-a-plugin

デバイスシミュレータープラグインを作成するには、[DeviceSimulatorPlugin](/engine/6000.0/script-reference/unityeditor/devicesimulation/devicesimulatorplugin.md) クラスを拡張します。

デバイスシミュレータービューに UI を挿入するには、プラグインで以下を行う必要があります。

* `title` プロパティをオーバーライドして、空ではない文字列を返します。
* UI を含む [VisualElement](/engine/6000.0/script-reference/unityengine/uielements/visualelement.md) を返すように `OnCreateUI` メソッドをオーバーライドします。

プラグインがこれらの条件を満たさない場合、デバイスシミュレーターはプラグインをインスタンス化しますが、シミュレータービューにその UI はディスプレイされません。

以下の例は、 title プロパティをオーバーライドし、シミュレータービューに UI を追加するプラグインの作成方法を示しています。

```lang-cs
public class TouchInfoPlugin : DeviceSimulatorPlugin
{
    public override string title => "Touch Info";
    private ラベル m_TouchCountLabel;
    private Label m_LastTouchEvent;
    private ボタン m_ResetCountButton;

    [SerializeField]
    private int m_TouchCount = 0;

    public override void OnCreate()
    {
        deviceSimulator.touchScreenInput += touchEvent =>
        {
            m_TouchCount += 1;
            UpdateTouchCounterText();
            m_LastTouchEvent.text = $"Last touch event: {touchEvent.phase.ToString()}";
        };
    }

    public override VisualElement OnCreateUI()
    {
        VisualElement root = new VisualElement();
        
        m_LastTouchEvent = new Label("Last touch event:なし
        
        m_TouchCountLabel = new Label();
        UpdateTouchCounterText();

        m_ResetCountButton = new Button {text = "Reset Count" };
        m_ResetCountButton.clicked += () =>
        {
            m_TouchCount = 0;
            UpdateTouchCounterText();
        };

        root.Add(m_LastTouchEvent);
        root.Add(m_TouchCountLabel);
        root.Add(m_ResetCountButton);
            
        return root;
    }

    private void UpdateTouchCounterText()
    {
        if (m_TouchCount > 0)
            m_TouchCountLabel.text = $"Touches recorded: {m_TouchCount}";
        else
            m_TouchCountLabel.text = "No taps recorded";
    }
}
```
