Exemplo n.º 1
0
        /// <summary>
        /// 自分のウィンドウハンドルが不確かならば探しなおす
        /// </summary>
        private void UpdateTargetWindow()
        {
            if (uniWinCore == null)
            {
                uniWinCore = new UniWinCore();
            }

            // ウィンドウがまだ取得できていなければ、取得の処理を行う
            if (!uniWinCore.IsActive)
            {
                uniWinCore.AttachMyWindow();

                // ウィンドウを取得できたら最初の値を設定
                if (uniWinCore.IsActive)
                {
                    uniWinCore.SetTransparentType(transparentType);
                    uniWinCore.SetKeyColor(keyColor);
                    SetTransparent(_isTransparent);
                    SetTopmost(_isTopmost);
                    SetClickThrough(_isClickThrough);
                    SetAllowDrop(_allowDropFiles);
                }
            }
            else
            {
                #if UNITY_EDITOR
                // エディタではゲームビューが閉じられたりドッキングされたりするため、変化していれば対象ウィンドウを変更
                // アクティブウィンドウが現在の対象と同じならばなにもおこらない
                uniWinCore.AttachMyActiveWindow();
                #endif
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Get monitor position and size
 /// </summary>
 /// <param name="index"></param>
 /// <returns></returns>
 public static Rect GetMonitorRect(int index)
 {
     if (UniWinCore.GetMonitorRectangle(index, out Vector2 position, out Vector2 size))
     {
         return(new Rect(position, size));
     }
     return(Rect.zero);
 }
Exemplo n.º 3
0
 public int GetDebugInfo()
 {
     if (_uniWinCore != null)
     {
         return(UniWinCore.GetDebugInfo());
     }
     return(0);
 }
Exemplo n.º 4
0
        // Use this for initialization
        void Awake()
        {
            // シングルトンとする。既にインスタンスがあれば自分を破棄
            if (this != current)
            {
                Destroy(this.gameObject);
                return;
            }
            else
            {
                _current = this;
            }

            // フルスクリーン強制解除。エディタでは何もしない
#if !UNITY_EDITOR
            if (forceWindowed && Screen.fullScreen)
            {
                Screen.fullScreen = false;
            }
#endif

            if (!currentCamera)
            {
                // メインカメラを探す
                currentCamera = Camera.main;

                //// もしメインカメラが見つからなければ、Findで探す
                //if (!currentCamera)
                //{
                //    currentCamera = GameObject.FindObjectOfType<Camera>();
                //}
            }

            // カメラの元の背景を記憶
            if (currentCamera)
            {
                originalCameraClearFlags = currentCamera.clearFlags;
                originalCameraBackground = currentCamera.backgroundColor;
            }

            // マウスイベント情報
            pointerEventData = new PointerEventData(EventSystem.current);

            // Ignore Raycast 以外を有効とするマスク
            hitTestLayerMask = ~LayerMask.GetMask("Ignore Raycast");

            // マウス下描画色抽出用テクスチャを準備
            colorPickerTexture = new Texture2D(1, 1, TextureFormat.ARGB32, false);

            // ウィンドウ制御用のインスタンス作成
            _uniWinCore = new UniWinCore();
        }
Exemplo n.º 5
0
        /// <summary>
        /// 自分のウィンドウハンドルが不確かならば探しなおす
        /// </summary>
        private void UpdateTargetWindow()
        {
            if (_uniWinCore == null)
            {
                _uniWinCore = new UniWinCore();
            }

            // ウィンドウがまだ取得できていなければ、取得の処理を行う
            if (!_uniWinCore.IsActive)
            {
                _uniWinCore.AttachMyWindow();

                // ウィンドウを取得できたら最初の値を設定
                if (_uniWinCore.IsActive)
                {
                    _uniWinCore.SetTransparentType((UniWinCore.TransparentType)transparentType);
                    _uniWinCore.SetKeyColor(keyColor);
                    _uniWinCore.SetAlphaValue(_alphaValue);
                    SetTransparent(_isTransparent);
                    if (_isBottommost)
                    {
                        SetBottommost(_isBottommost);
                    }
                    else
                    {
                        SetTopmost(_isTopmost);
                    }
                    SetZoomed(_isZoomed);
                    SetClickThrough(_isClickThrough);
                    SetAllowDrop(_allowDropFiles);

                    // ウィンドウ取得時にはモニタ変更と同等の処理を行う
                    OnMonitorChanged?.Invoke();
                }
            }
            else
            {
                #if UNITY_EDITOR
                // エディタではゲームビューが閉じられたりドッキングされたりするため、変化していれば対象ウィンドウを変更
                // アクティブウィンドウが現在の対象と同じならばなにもおこらない
                _uniWinCore.AttachMyActiveWindow();
                #endif
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Fit to specified monitor
        /// </summary>
        private void UpdateMonitorFitting()
        {
            if (!_shouldFitMonitor)
            {
                return;
            }

            int monitors           = UniWinCore.GetMonitorCount();
            int targetMonitorIndex = _monitorToFit;

            if (targetMonitorIndex < 0)
            {
                targetMonitorIndex = 0;
            }
            if (monitors <= targetMonitorIndex)
            {
                targetMonitorIndex = monitors - 1;
            }

            if (targetMonitorIndex >= 0)
            {
                _uniWinCore.FitToMonitor(targetMonitorIndex);
            }
        }
Exemplo n.º 7
0
 /// <summary>
 /// Get the number of connected monitors
 /// </summary>
 /// <returns></returns>
 public static int GetMonitorCount()
 {
     //if (uniWinCore == null) return 0;
     return(UniWinCore.GetMonitorCount());
 }
Exemplo n.º 8
0
 /// <summary>
 /// Set mouse cursor position
 /// </summary>
 /// <param name="position"></param>
 public static void SetCursorPosition(Vector2 position)
 {
     UniWinCore.SetCursorPosition(position);
 }
Exemplo n.º 9
0
 /// <summary>
 /// Get mouse cursor position
 /// </summary>
 /// <returns>Cursor position</returns>
 public static Vector2 GetCursorPosition()
 {
     return(UniWinCore.GetCursorPosition());
 }