npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

com.hidano.runtime-display-selector

v0.1.1

Published

Unity URP 向け、実行時に Camera / RenderTexture を論理ディスプレイへアサインして Spout センダーで送出するパッケージ。

Downloads

31

Readme

Runtime Display Selector

Unity 上の Camera または RenderTexture を Spout センダーとして送出し、受信側アプリ (OBS Studio / TouchDesigner など) から任意の物理ディスプレイへ出力するための Unity パッケージです。

ドキュメントは現時点で日本語のみです。

主な特徴

  • 実行時に任意の Camera / RenderTexture を論理ディスプレイ番号にアサインし、Spout センダーとして送出
  • 1 プロジェクトから複数センダーを同時送出 (マルチディスプレイ運用)
  • アサイン状態の JSON 永続化と復元
  • センダー名プリフィックスのカスタマイズ (他アプリ・他プロセスとの名前衝突回避)
  • 同一 Camera を複数論理ディスプレイへミラー送出
  • 同一論理ディスプレイ内の ViewportRect 分割 (Split View)
  • アルファ透過送出 (RenderTexture モード + URP Alpha Output)
  • MonoBehaviour Facade による Inspector 操作と、ランタイム API の双方を提供

動作環境

  • Unity 6.3 (6000.3) 以上
  • Universal Render Pipeline (URP) 17.3.0 以上
  • Windows 10 / 11 (x86 / x64 Standalone および Editor Play Mode)

インストール

1. KlakSpout を先に導入する

本パッケージは KlakSpout (jp.keijiro.klak.spout 2.0.6 以上) に依存しますが、社内ホスティング環境などとのレジストリ衝突を避けるため package.json には依存宣言していません。先にプロジェクト側で導入しておいてください。

公開レジストリ (npmjs.com) から取得する場合は Packages/manifest.json に次を追記します。

{
  "scopedRegistries": [
    {
      "name": "Keijiro",
      "url": "https://registry.npmjs.com",
      "scopes": ["jp.keijiro"]
    }
  ],
  "dependencies": {
    "jp.keijiro.klak.spout": "2.0.6"
  }
}

2. 本パッケージを追加する

Window > Package Manager > +Install package from git URL... に次を入力します。

https://github.com/Hidano-Dev/RuntimeDisplaySelector.git?path=RuntimeDisplaySelector/Packages/com.hidano.runtime-display-selector

特定タグ / コミットへ pin する場合は URL 末尾に #0.1.0 のように付与してください。

Packages/manifest.json に直接書く場合:

{
  "dependencies": {
    "com.hidano.runtime-display-selector": "https://github.com/Hidano-Dev/RuntimeDisplaySelector.git?path=RuntimeDisplaySelector/Packages/com.hidano.runtime-display-selector#0.1.0"
  }
}

依存関係

| パッケージ | バージョン | 備考 | |---|---|---| | com.unity.render-pipelines.universal | 17.3.0 以上 | Unity Registry (自動解決) | | com.unity.nuget.newtonsoft-json | 3.2.1 以上 | Unity Registry (自動解決) | | jp.keijiro.klak.spout | 2.0.6 以上 | 手動導入 (上記 1 を参照) |

クイックスタート

Inspector から使う

  1. シーンに RuntimeDisplaySelector Prefab (Packages/Runtime Display Selector/Runtime/Prefabs/RuntimeDisplaySelector.prefab) を配置します。
  2. Inspector の Initial Assignments リストに、対象 Camera (または RenderTexture) と論理ディスプレイ番号を追加します。
  3. 必要に応じて Sender Naming Policy のプリフィックス (既定: RuntimeDisplaySelector_Display_) を変更します。
  4. Play Mode で起動すると、各エントリが Spout センダーとして送出されます。

スクリプトから使う

using Hidano.RuntimeDisplaySelector;

var selector = RuntimeDisplaySelector.Current;

// Camera をディスプレイ 0 にアサイン
selector.AssignCameraToDisplay(myCamera, displayIndex: 0);

// RenderTexture をディスプレイ 1 にアサイン (アルファ透過などの用途)
selector.AssignRenderTextureToDisplay(myRenderTexture, displayIndex: 1);

// 解除
selector.UnassignDisplay(displayIndex: 0);

// アサイン状態を保存 / 復元
selector.SaveAssignments();
selector.RestoreAssignments();

// センダー名プリフィックスをコードから変更
selector.SenderNamingPolicy = new SenderNamingPolicy("MyApp_Display_");

// 検出されたディスプレイ一覧を取得
foreach (var d in selector.GetDisplays())
{
    Debug.Log($"Display {d.Index}: {d.FriendlyName} ({d.Width}x{d.Height})");
}

送出されるセンダー名は <prefix><displayIndex> (例: RuntimeDisplaySelector_Display_0) となります。受信側アプリでこの名前を選択してください。

サンプル

Package Manager 上で本パッケージを選択し、Samples タブから個別にインポートできます。

  • Minimal Display Assignment — Camera を論理ディスプレイ 0 にアサインする最小例
  • Split View (Multiple Cameras) — 複数 Camera を 1 つの論理ディスプレイに ViewportRect で分割配置
  • Runtime Switching (API)RuntimeDisplaySelector.Current 経由でキー入力からアサインを動的に切り替え

アサイン状態の保存先

既定の保存先は StreamingAssets/runtime-display-selector.json です。Standalone を Program Files 配下にインストールするなど StreamingAssets が書き込み禁止になる環境では、Application.persistentDataPath 配下の絶対パスを Inspector の Assignment File Path または API 引数で指定してください。

var path = System.IO.Path.Combine(
    Application.persistentDataPath,
    "runtime-display-selector.json");

selector.AssignmentFilePath = path;
selector.SaveAssignments();
selector.RestoreAssignments();

トラブルシューティング

DisplayInfo.Width / Height が物理解像度と一致しない

NVIDIA DSR や Windows の DPI スケーリング環境で、GetDisplays() の返す解像度が実機と乖離することがあります。Unity プロセスを per-monitor DPI aware として宣言してください。

  • Player Settings: Edit > Project Settings > Player > Resolution and Presentation の DPI Awareness 系オプションを有効化
  • アプリマニフェスト (Standalone Windows): ビルド出力先の <AppName>.exe.manifest に以下を追加
<asmv3:windowsSettings>
  <dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true/PM</dpiAware>
  <dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2</dpiAwareness>
</asmv3:windowsSettings>

復元時に「対応する Camera が見つからない」と警告が出る

シーン上の同名兄弟 Camera (Cameras/Camera[0], Cameras/Camera[1] …) が動的に増減 / 並び替えされると、保存時の兄弟インデックスがずれて復元に失敗することがあります。runtime-display-selector.jsonCameraPath フィールドを実シーンに合わせて手編集してください。

// 編集前
{ "CameraPath": "Cameras/Camera[1]", "DisplayIndex": 1, "ViewportRect": null, "SenderName": null }
// 編集後
{ "CameraPath": "Cameras/Camera[0]", "DisplayIndex": 1, "ViewportRect": null, "SenderName": null }

DontDestroyOnLoad 配下の Camera は [DontDestroyOnLoad]/...、加算ロードシーン配下は <sceneName>::... のプレフィックスを付与します。

Spout センダー名が他プロセスと衝突する

複数 Unity プロセス (Editor + Standalone など) を同時起動すると、既定プリフィックスのセンダー名が衝突して受信側で意図しない映像が見えることがあります。SenderNamingPolicy のプリフィックスをアプリ固有の値に変更してください。

selector.SenderNamingPolicy = new SenderNamingPolicy("MyApp_Display_");

受信側アプリのセンダー名指定も新しい名前に追従して更新してください。

ライセンス

本パッケージは MIT License で配布されます。詳細は LICENSE を参照してください。