Skip to content

Windowsで動作するUnityのスタンドアロンプレイヤーのメインウィンドウのウィンドウハンドルを取得する機能 / This feature gets the Unity Standalone Player main window handle running on Windows

License

MIT, Unknown licenses found

Licenses found

MIT
LICENSE
Unknown
LICENSE.meta
Notifications You must be signed in to change notification settings

HWataame/UnityPlayerWindowHandle

Repository files navigation

UnityPlayer Window Handle

概要 / Overview

Windowsで動作するUnityのスタンドアロンプレイヤーのメインウィンドウのウィンドウハンドルを取得する機能を提供します

Get the Unity Standalone Player main window handle running on Windows

動作環境 / Requirements

  • Windows 11(21H2以上)

    Windows 11 (version 21H2 or later)

  • Unity 2021.3以上

    Unity 2021.3 or later

  • Api Compatibility Level: .NET Standard 2.1

動作を確認した環境 / Verified Environment

  • Windows 11 24H2 (26100)
  • Unity 2021.3.45f1, Unity 2022.3.62f1, Unity 6000.0.54f1, Unity 6000.1.13f1

使用方法 / English "Usage" is below this

名前空間HW.UnityPlayerWindowHandle内のUnityPlayerWindow.IsHandleValidの値がtrueであれば、UnityPlayerWindow.MainWindowHandleからスタンドアロンプレイヤーのメインウィンドウのウィンドウハンドルを取得できます

if(HW.UnityPlayerWindowHandle.UnityPlayerWindow.IsHandleValid)
{
    // IsHandleValidがtrueであればウィンドウハンドルを取得できる
    nint windowHandle = HW.UnityPlayerWindowHandle.UnityPlayerWindow.MainWindowHandle;

    // 以下、ウィンドウハンドルを使った処理など
    // ...
}

Usage / 日本語の「使用方法」は上にあります

If UnityPlayerWindow.IsHandleValid(namespace: HW.UnityPlayerWindowVisual) returns true, UnityPlayerWindow.MainWindowHandle(namespace: HW.UnityPlayerWindowVisual) returns the Unity Standalone Player main window handle

if(HW.UnityPlayerWindowHandle.UnityPlayerWindow.IsHandleValid)
{
    // If IsHandleValid returns true, MainWindowHandle is available
    nint windowHandle = HW.UnityPlayerWindowHandle.UnityPlayerWindow.MainWindowHandle;

    // Process with window handle
    // ...
}

その他の仕様 / Other specifications

  • このパッケージを導入するとHAS_COMMON_MAIN_WINDOW_HANDLE_GETTER_HWというDefine Symbolがプロジェクトに設定されます。 また、アンインストールするとHAS_COMMON_MAIN_WINDOW_HANDLE_GETTER_HWは自動で除去されます

    When install this package, a Define Symbol HAS_COMMON_MAIN_WINDOW_HANDLE_GETTER_HW will be added to installed project automatically. And, When uninstall this package, HAS_COMMON_MAIN_WINDOW_HANDLE_GETTER_HW will be removed from the project automatically

  • 1.0.1以上では、SubsystemRegistrationのタイミング(メインウィンドウが表示される前)に自動的にウィンドウハンドルを取得する処理が実行されます。 プロジェクトのDefine SymbolにSUPPRESS_AUTO_GET_WINDOW_HANDLE_HWを指定すると、自動取得を無効にできます

    On 1.0.1 or greater, will be getting Standalone Player main window handle when SubsystemRegistration timing. If set SUPPRESS_AUTO_GET_WINDOW_HANDLE_HW to Define Symbol in Project Setting, auto getting will be disabled

導入方法 / English "How to introduction" is below this

  1. Gitをインストールする

  2. 追加したいプロジェクトを開き、Package Managerを開く

  3. 以下のGit URLをコピー、またはこのページ上部の「<> Code」からClone URLをコピーする

    https://github.com/HWataame/UnityPlayerWindowHandle.git

  4. 「Package Manager」ウィンドウの左上の「+」ボタンをクリックし、「Install package from git URL...」を選択する

    導入方法01
  5. 入力欄に手順2でコピーしたURLを貼り付け、「Install」ボタンを押す

    導入方法02
  6. (必要に応じて)Assembly Definition Assetの管理下のエディターコードで利用する場合は、HW.UnityPlayerWindowHandleをAssembly Definition Referencesに追加する

    導入方法03(必要に応じて)

How to introduction / 日本語の「導入方法」は上にあります

  1. Install Git to your computer.

  2. Open Package Manager in the Unity project to which you want to add this feature.

  3. Copy the following Git URL, or copy the Clone URL from "<> Code" at the top of this page

    https://github.com/HWataame/UnityPlayerWindowHandle.git

  4. Click the "+" button in the "Package Manager" window and select "Install package from git URL...".

    導入方法01
  5. Paste the URL copied in Step 2 into the input field and press the "Install" button.

    導入方法02
  6. (If necessary) For use in editor code under the control of Assembly Definition Asset...

    Add HW.UnityPlayerWindowHandle to "Assembly Definition References" in your Assembly Definition Asset.

    導入方法03(必要に応じて)

ライセンス / License

MITライセンスです

Using "MIT license"

About

Windowsで動作するUnityのスタンドアロンプレイヤーのメインウィンドウのウィンドウハンドルを取得する機能 / This feature gets the Unity Standalone Player main window handle running on Windows

Resources

License

MIT, Unknown licenses found

Licenses found

MIT
LICENSE
Unknown
LICENSE.meta

Stars

Watchers

Forks

Packages

No packages published

Languages