Esempio n. 1
0
        /// <summary>
        /// モニタ選択ドロップダウンの選択肢を更新
        /// この後にUpdateUI()を呼ぶこと
        /// </summary>
        void UpdateMonitorDropdown()
        {
            if (!fitWindowDropdown)
            {
                return;
            }

            // 先頭以外の選択肢を削除
            fitWindowDropdown.options.RemoveRange(1, fitWindowDropdown.options.Count - 1);

            if (!uniwinc)
            {
                fitWindowDropdown.value = 0;
            }
            else
            {
                int count = UniWindowController.GetMonitorCount();
                for (int i = 0; i < count; i++)
                {
                    fitWindowDropdown.options.Add(new Dropdown.OptionData("Fit to Monitor " + i));
                }
                if (uniwinc.monitorToFit >= count)
                {
                    uniwinc.monitorToFit = count - 1;
                }
            }
        }
        // Start is called before the first frame update
        void Start()
        {
            // シーン中の UniWindowController を取得
            _uniwinc = GameObject.FindObjectOfType <UniWindowController>();
            if (_uniwinc)
            {
                _isHitTestEnabled = _uniwinc.isHitTestEnabled;
            }

            //// ↓なくても良さそうなので勝手に変更しないようコメントアウト
            //Input.simulateMouseWithTouches = false;
        }
Esempio n. 3
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();
        }
Esempio n. 4
0
        void OnDestroy()
        {
            if (_uniWinCore != null)
            {
                _uniWinCore.Dispose();
            }

            // Instance も破棄
            if (this == current)
            {
                _current = null;
            }
        }
        /// <summary>
        /// 初期化
        /// </summary>
        void Start()
        {
            // UniWindowController を探す
            uniwinc = GameObject.FindObjectOfType <UniWindowController>();

            // UniWindowDragMove を探す
            uniWinMoveHandle = GameObject.FindObjectOfType <UniWindowMoveHandle>();

            // Toggleのチェック状態を、現在の状態に合わせる
            UpdateUI();

            if (uniwinc)
            {
                // UIを操作された際にはウィンドウに反映されるようにする
                transparentToggle?.onValueChanged.AddListener(val => uniwinc.isTransparent = val);
                topmostToggle?.onValueChanged.AddListener(val => uniwinc.isTopmost         = val);
                zoomedToggle?.onValueChanged.AddListener(val => uniwinc.isZoomed           = val);
                allowDropToggle?.onValueChanged.AddListener(val => uniwinc.allowDropFiles  = val);

                widthDownButton?.onClick.AddListener(() => uniwinc.windowSize  += new Vector2(-100, 0));
                widthUpButton?.onClick.AddListener(() => uniwinc.windowSize    += new Vector2(+100, 0));
                heightDownButton?.onClick.AddListener(() => uniwinc.windowSize += new Vector2(0, -100));
                heightUpButton?.onClick.AddListener(() => uniwinc.windowSize   += new Vector2(0, +100));

                clickThroughToggle?.onValueChanged.AddListener(val => uniwinc.isClickThrough = val);

                transparentTypeDropdown?.onValueChanged.AddListener(val => uniwinc.SetTransparentType((UniWinCore.TransparentType)val));
                hitTestTypeDropdown?.onValueChanged.AddListener(val => uniwinc.hitTestType = (UniWindowController.HitTestType)val);
                menuCloseButton?.onClick.AddListener(CloseMenu);

                if (uniWinMoveHandle)
                {
                    dragMoveToggle?.onValueChanged.AddListener(val => uniWinMoveHandle.enabled = val);
                }

#if UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX
                // Windows でなければ、透過方法の選択は無効とする
                //if (transparentTypeDropdown) transparentTypeDropdown.interactable = false;
                //if (transparentTypeDropdown) transparentTypeDropdown.enabled = false;
                if (transparentTypeDropdown)
                {
                    transparentTypeDropdown.gameObject.SetActive(false);
                }
#endif

                // Add events
                uniwinc.OnDisplayChanged += () => { ShowEventMessage("Display changed!"); };
                uniwinc.OnDropFiles      += files => { ShowEventMessage(string.Join(Environment.NewLine, files)); };
            }
        }
        /// <summary>
        /// 初期化
        /// </summary>
        void Start()
        {
            // UniWindowController を探す
            uniwinc = GameObject.FindObjectOfType <UniWindowController>();

            // CanvasのRectTransform取得
            if (menuPanel)
            {
                canvasRect = menuPanel.GetComponentInParent <Canvas>().GetComponent <RectTransform>();
            }

            // 有効なモニタ数に合わせて選択肢を作成
            UpdateMonitorDropdown();

            // Toggleのチェック状態を、現在の状態に合わせる
            UpdateUI();

            // 初期状態ではメニューを閉じておく
            CloseMenu();

            if (uniwinc)
            {
                // UIを操作された際にはウィンドウに反映されるようにする
                transparentToggle?.onValueChanged.AddListener(val => uniwinc.isTransparent = val);
                topmostToggle?.onValueChanged.AddListener(val => uniwinc.isTopmost         = val);
                bottommostToggle?.onValueChanged.AddListener(val => uniwinc.isBottommost   = val);
                fitWindowDropdown?.onValueChanged.AddListener(val => SetFitToMonitor(val));
                quitButton?.onClick.AddListener(Quit);
                menuCloseButton?.onClick.AddListener(CloseMenu);

                // Add events
                uniwinc.OnStateChanged += () =>
                {
                    UpdateUI();
                    //ShowEventMessage("Style changed");
                };
                uniwinc.OnMonitorChanged += () => {
                    UpdateMonitorDropdown();
                    UpdateUI();
                    //ShowEventMessage("Resolution changed!");
                };
            }
        }
        // Start is called before the first frame update
        void Start()
        {
            //UniWinCore.DebugMonitorInfo();

            uniwin = GameObject.FindObjectOfType <UniWindowController>();
        }
Esempio n. 8
0
        /// <summary>
        /// 初期化
        /// </summary>
        void Start()
        {
            // UniWindowController を探す
            uniwinc = UniWindowController.current;

            // UniWindowDragMove を探す
            uniWinMoveHandle = GameObject.FindObjectOfType <UniWindowMoveHandle>();

            // CanvasのRectTransform取得
            if (menuPanel)
            {
                canvasRect = menuPanel.GetComponentInParent <Canvas>().GetComponent <RectTransform>();
            }

            // 有効なモニタ数に合わせて選択肢を作成
            UpdateMonitorDropdown();

            // Toggleのチェック状態を、現在の状態に合わせる
            UpdateUI();

            if (uniwinc)
            {
                // UIを操作された際にはウィンドウに反映されるようにする
                transparentToggle?.onValueChanged.AddListener(val => uniwinc.isTransparent = val);
                alphaSlider?.onValueChanged.AddListener(val => uniwinc.alphaValue          = val);
                topmostToggle?.onValueChanged.AddListener(val => uniwinc.isTopmost         = val);
                bottommostToggle?.onValueChanged.AddListener(val => uniwinc.isBottommost   = val);
                zoomedToggle?.onValueChanged.AddListener(val => uniwinc.isZoomed           = val);
                allowDropToggle?.onValueChanged.AddListener(val => uniwinc.allowDropFiles  = val);

                fitWindowDropdown?.onValueChanged.AddListener(val => SetFitToMonitor(val));

                widthDownButton?.onClick.AddListener(() => uniwinc.windowSize  += new Vector2(-100, 0));
                widthUpButton?.onClick.AddListener(() => uniwinc.windowSize    += new Vector2(+100, 0));
                heightDownButton?.onClick.AddListener(() => uniwinc.windowSize += new Vector2(0, -100));
                heightUpButton?.onClick.AddListener(() => uniwinc.windowSize   += new Vector2(0, +100));

                clickThroughToggle?.onValueChanged.AddListener(val => uniwinc.isClickThrough = val);

                transparentTypeDropdown?.onValueChanged.AddListener(val => uniwinc.SetTransparentType((UniWindowController.TransparentType)val));
                hitTestTypeDropdown?.onValueChanged.AddListener(val => uniwinc.hitTestType = (UniWindowController.HitTestType)val);
                menuCloseButton?.onClick.AddListener(CloseMenu);

                if (uniWinMoveHandle)
                {
                    dragMoveToggle?.onValueChanged.AddListener(val => uniWinMoveHandle.enabled = val);
                }

#if UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX
                // Windows でなければ、透過方法の選択は無効とする
                //if (transparentTypeDropdown) transparentTypeDropdown.interactable = false;
                //if (transparentTypeDropdown) transparentTypeDropdown.enabled = false;
                if (transparentTypeDropdown)
                {
                    transparentTypeDropdown.gameObject.SetActive(false);
                }
#endif

                // Add events
                uniwinc.OnStateChanged += (type) =>
                {
                    UpdateUI();
                    //Debug.Log("Window state changed: " + type);
                    ShowEventMessage("State changed: " + type);
                    //ShowEventMessage("State changed: " + type + "4:isKey 2:canBecomeKey, 1:canBecomeMain  : " + uniwinc.GetDebugInfo().ToString());
                };
                uniwinc.OnMonitorChanged += () => {
                    UpdateMonitorDropdown();
                    UpdateUI();
                    ShowEventMessage("Resolution changed!");
                };
                uniwinc.OnDropFiles += files =>
                {
                    ShowEventMessage(string.Join(Environment.NewLine, files));
                };
            }

            // UinWinCが準備できてなくても動くListener
            showBorderlineToggle?.onValueChanged.AddListener(val => borderlinePanel.gameObject.SetActive(val));
        }