コード例 #1
0
        /// <summary>
        /// Set the window alpha
        /// </summary>
        /// <param name="alpha">0.0 - 1.0</param>
        public void SetAlphaValue(float alpha)
        {
            // Windowsのエディタでは、一度半透明にしてしまうと表示が更新されなくなるため無効化。MacならOK
#if !UNITY_EDITOR_WIN
            LibUniWinC.SetAlphaValue(alpha);
#endif
        }
コード例 #2
0
        /// <summary>
        /// Get the window Size.
        /// </summary>
        /// <returns>The Size.</returns>
        public Vector2 GetWindowSize()
        {
            Vector2 size = Vector2.zero;

            LibUniWinC.GetSize(out size.x, out size.y);
            return(size);
        }
コード例 #3
0
        /// <summary>
        /// Get the mouse pointer position.
        /// </summary>
        /// <returns>The position.</returns>
        public Vector2 GetCursorPosition()
        {
            Vector2 pos = Vector2.zero;

            LibUniWinC.GetCursorPosition(out pos.x, out pos.y);
            return(pos);
        }
コード例 #4
0
        /// <summary>
        /// Fit the window to specified monitor
        /// </summary>
        /// <param name="monitorIndex"></param>
        /// <returns></returns>
        public bool FitToMonitor(int monitorIndex)
        {
            float dx, dy, dw, dh;

            if (LibUniWinC.GetMonitorRectangle(monitorIndex, out dx, out dy, out dw, out dh))
            {
                // 最大化状態なら一度戻す
                if (LibUniWinC.IsMaximized())
                {
                    LibUniWinC.SetMaximized(false);
                }

                // 指定モニタ中央座標
                float cx = dx + (dw / 2);
                float cy = dy + (dh / 2);

                // ウィンドウ中央を指定モニタ中央に移動
                float ww, wh;
                LibUniWinC.GetSize(out ww, out wh);
                float wx = cx - (ww / 2);
                float wy = cy - (wh / 2);
                LibUniWinC.SetPosition(wx, wy);

                // 最大化
                LibUniWinC.SetMaximized(true);

                //Debug.Log(String.Format("Monitor {4} : {0},{1} - {2},{3}", dx, dy, dw, dh, monitorIndex));
                return(true);
            }
            return(false);
        }
コード例 #5
0
        /// <summary>
        /// 終了時の処理
        /// </summary>
        public void Dispose()
        {
            // 最後にウィンドウ状態を戻すとそれが目についてしまうので、あえて戻さないことにしてみるためコメントアウト
            //DetachWindow();

            // Instead of DetachWindow()
            LibUniWinC.UnregisterDropFilesCallback();
        }
コード例 #6
0
        /// <summary>
        /// クリックスルーを設定/解除
        /// </summary>
        /// <param name="isThrough"></param>
        public void EnableClickThrough(bool isThrough)
        {
            // エディタでクリックスルーされると操作できなくなる可能性があるため、スキップ
#if !UNITY_EDITOR
            LibUniWinC.SetClickThrough(isThrough);
#endif
            this._isClickThrough = isThrough;
        }
コード例 #7
0
        /// <summary>
        /// 透過を設定/解除
        /// </summary>
        /// <param name="isTransparent"></param>
        public void EnableTransparent(bool isTransparent)
        {
            // エディタは透過できなかったり、枠が通常と異なるのでスキップ
#if !UNITY_EDITOR
            LibUniWinC.SetTransparent(isTransparent);
            LibUniWinC.SetBorderless(isTransparent);
#endif
            this._isTransparent = isTransparent;
        }
コード例 #8
0
        /// <summary>
        /// ウィンドウ状態を最初に戻して操作対象から解除
        /// </summary>
        public void DetachWindow()
        {
#if UNITY_EDITOR
            // エディタの場合、ウィンドウスタイルでは常に最前面と得られていない可能性があるため、
            //  最前面ではないのが本来と決め打ちで、デタッチ時無効化する
            EnableTopmost(false);
#endif
            LibUniWinC.DetachWindow();
        }
コード例 #9
0
    /// <summary>
    /// Fit the window to specified monitor
    /// </summary>
    /// <param name="monitorIndex"></param>
    /// <returns></returns>
    public bool FitToMonitor(int monitorIndex)
    {
        float x, y, width, height;

        if (LibUniWinC.GetMonitorRectangle(monitorIndex, out x, out y, out width, out height))
        {
            LibUniWinC.SetPosition(x, y);
            LibUniWinC.SetSize(width, height);
            return(true);
        }
        return(false);
    }
コード例 #10
0
        /// <summary>
        /// 自分のウィンドウ(ゲームビューが独立ウィンドウならそれ)を探して操作対象とする
        /// </summary>
        /// <returns></returns>
        public bool AttachMyWindow()
        {
#if UNITY_EDITOR_WIN
            // 確実にゲームビューを得る方法がなさそうなので、フォーカスを与えて直後にアクティブなウィンドウを取得
            var gameView = GetGameView();
            if (gameView)
            {
                gameView.Focus();
                LibUniWinC.AttachMyActiveWindow();
            }
#else
            LibUniWinC.AttachMyWindow();
#endif
            IsActive = LibUniWinC.IsActive();
            return(IsActive);
        }
コード例 #11
0
        public static void DebugMonitorInfo()
        {
            int monitors = LibUniWinC.GetMonitorCount();

            int currentMonitorIndex = LibUniWinC.GetCurrentMonitor();

            string message = "Current monitor: " + currentMonitorIndex + "\r\n";

            for (int i = 0; i < monitors; i++)
            {
                float x, y, w, h;
                bool  result = LibUniWinC.GetMonitorRectangle(i, out x, out y, out w, out h);
                message += String.Format(
                    "Monitor {0}: X:{1}, Y:{2} - W:{3}, H:{4}\r\n",
                    i, x, y, w, h
                    );
            }
            Debug.Log(message);
        }
コード例 #12
0
        /// <summary>
        /// 自分のウィンドウ(ゲームビューが独立ウィンドウならそれ)を探して操作対象とする
        /// </summary>
        /// <returns></returns>
        public bool AttachMyWindow()
        {
#if UNITY_EDITOR_WIN
            // 確実にゲームビューを得る方法がなさそうなので、フォーカスを与えて直後にアクティブなウィンドウを取得
            var gameView = GetGameView();
            if (gameView)
            {
                gameView.Focus();
                LibUniWinC.AttachMyActiveWindow();
            }
#else
            LibUniWinC.AttachMyWindow();
#endif
            // Add event handlers
            LibUniWinC.RegisterDropFilesCallback(_droppedFilesCallback);

            IsActive = LibUniWinC.IsActive();
            return(IsActive);
        }
コード例 #13
0
 /// <summary>
 /// 単色透過の場合の透明色を指定(Windowsのみ対応)
 /// </summary>
 /// <param name="color"></param>
 public void SetKeyColor(Color32 color)
 {
     LibUniWinC.SetKeyColor((UInt32)(color.b * 0x10000 + color.g * 0x100 + color.r));
     keyColor = color;
 }
コード例 #14
0
 /// <summary>
 /// 自分のプロセスで現在アクティブなウィンドウを選択
 /// エディタの場合、ウィンドウが閉じたりドッキングしたりするため、フォーカス時に呼ぶ
 /// </summary>
 /// <returns></returns>
 public bool AttachMyActiveWindow()
 {
     LibUniWinC.AttachMyActiveWindow();
     IsActive = LibUniWinC.IsActive();
     return(IsActive);
 }
コード例 #15
0
 /// <summary>
 /// 透過方法を指定(Windowsのみ対応)
 /// </summary>
 /// <param name="type"></param>
 public void SetTransparentType(TransparentType type)
 {
     LibUniWinC.SetTransparentType((Int32)type);
     transparentType = type;
 }
コード例 #16
0
 public void SetAllowDrop(bool enabled)
 {
     LibUniWinC.SetAllowDrop(enabled);
 }
コード例 #17
0
 /// <summary>
 /// Set the mouse pointer position.
 /// </summary>
 /// <param name="position">Position.</param>
 public void SetCursorPosition(Vector2 position)
 {
     LibUniWinC.SetCursorPosition(position.x, position.y);
 }
コード例 #18
0
 /// <summary>
 /// Set the window Size.
 /// </summary>
 /// <param name="size">Size.</param>
 public void SetWindowSize(Vector2 size)
 {
     LibUniWinC.SetSize(size.x, size.y);
 }
コード例 #19
0
 /// <summary>
 /// Call this periodically to maintain window style
 /// </summary>
 public void Update()
 {
     LibUniWinC.Update();
 }
コード例 #20
0
 public int GetMyProcessId()
 {
     return(LibUniWinC.GetMyProcessId());
 }
コード例 #21
0
 public bool GetMonitorRectangle(int index, out Vector2 position, out Vector2 size)
 {
     return(LibUniWinC.GetMonitorRectangle(index, out position.x, out position.y, out size.x, out size.y));
 }
コード例 #22
0
 /// <summary>
 /// Get the monitor index where the window is located
 /// </summary>
 /// <returns>Monitor index</returns>
 public int GetCurrentMonitor()
 {
     return(LibUniWinC.GetCurrentMonitor());
 }
コード例 #23
0
 /// <summary>
 /// Set the window alpha
 /// </summary>
 /// <param name="alpha">0.0 - 1.0</param>
 public void SetAlphaValue(float alpha)
 {
     LibUniWinC.SetAlphaValue(alpha);
 }
コード例 #24
0
 /// <summary>
 /// Set the window z-order (Bottommost or not).
 /// </summary>
 /// <param name="isBottommost">If set to <c>true</c> is bottom.</param>
 public void EnableBottommost(bool isBottommost)
 {
     LibUniWinC.SetBottommost(isBottommost);
     this._isBottommost = isBottommost;
     this._isTopmost    = false; // Exclusive
 }
コード例 #25
0
 /// <summary>
 /// Get the number of connected monitors
 /// </summary>
 /// <returns>Count</returns>
 public int GetMonitorCount()
 {
     return(LibUniWinC.GetMonitorCount());
 }
コード例 #26
0
 /// <summary>
 /// Set the window position.
 /// </summary>
 /// <param name="position">Position.</param>
 public void SetWindowPosition(Vector2 position)
 {
     LibUniWinC.SetPosition(position.x, position.y);
 }
コード例 #27
0
 /// <summary>
 /// ウィンドウを最大化(Macではズーム)する
 /// 最大化された後にサイズ変更がされることもあり、現状、確実には動作しない可能性があります
 /// </summary>
 public void SetZoomed(bool isZoomed)
 {
     LibUniWinC.SetMaximized(isZoomed);
 }
コード例 #28
0
 public IntPtr GetWindowHandle()
 {
     return(LibUniWinC.GetWindowHandle());
 }
コード例 #29
0
 public static int GetDebugInfo()
 {
     return(LibUniWinC.GetDebugInfo());
 }
コード例 #30
0
 /// <summary>
 /// ウィンドウが最大化(Macではズーム)されているかを取得
 /// 最大化された後にサイズ変更がされることもあり、現状、確実には動作しない可能性があります
 /// </summary>
 public bool GetZoomed()
 {
     return(LibUniWinC.IsMaximized());
 }