/// <summary>
        /// 自ウィンドウと思われるハンドルを取得
        /// </summary>
        /// <returns>Null if failed</returns>
        static public WindowHandle FindWindow()
        {
            // 自分自身のPIDを取得し、スレッドを取得
            System.Diagnostics.Process process = System.Diagnostics.Process.GetCurrentProcess();
            //return new WindowHandle(process.MainWindowHandle);	// ←これではダメだった。MainWindowHandle == 0 となった。

            int pid = process.Id;

            //Debug.Log("PID: " + pid);

#if UNITY_EDITOR
            // Gameビューを取得
            // 参考: https://qiita.com/MARQUE/items/292c9080a686d95af1a5
            var gameViewWin = UnityEditor.EditorWindow.GetWindow(System.Type.GetType("UnityEditor.GameView,UnityEditor"));

            // Gameビューににフォーカスを与えてから、アクティブなウィンドウを取得
            gameViewWin.Focus();
            //System.Threading.Thread.Sleep(100);
            IntPtr hwnd = WinApi.GetActiveWindow();

            var rootHwnd = hwnd;
            rootHwnd = WinApi.GetAncestor(hwnd, WinApi.GA_ROOT);

            WindowHandle gameWindow = new WindowHandle(rootHwnd);

            // 一応PIDをチェックし、自分一致したらそのウィンドウを使うことにして終了
            if (gameWindow.ProcessId == pid)
            {
                return(gameWindow);
            }
#else
            IntPtr hwnd;
#endif

            // アクティブウィンドウを取得する方法
            hwnd = WinApi.GetActiveWindow();
            if (hwnd == IntPtr.Zero)
            {
                return(null);
            }
            //Debug.Log("Active HWND:" + hwnd);

            WindowHandle window = new WindowHandle(hwnd);
            if (window.ProcessId != pid)
            {
                return(null);
            }
            return(window);


            //// 現存するウィンドウ一式を取得してPIDが一致するものを利用する方法
            //WindowHandle[] handles = FindWindows();
            //foreach (WindowHandle window in handles)
            //{
            //    Debug.Log(window);

            //    // PIDが一致するものを検索
            //    if (window.ProcessId == pid)
            //    {
            //        return window;
            //    }
            //}
            //return null;
        }