public int Count()
        {
            // "Play Normal" and "Play Maximized" should always be options.
            // The play fullscreen option will be added per-display.
            int optionCount = GameViewOnPlayMenu.kPlayModeBaseOptionCount;

            optionCount += EditorFullscreenController.GetConnectedDisplayNames().Length;
            return(optionCount);
        }
        private static void ActivateDisplayImpl(IntPtr nativeDisplay, int width, int height, int refreshRate)
        {
            var manager = instance;

            if (manager.m_mode == DisplayAPIControlMode.FromRuntime)
            {
                EditorFullscreenController.BeginFullscreen((int)nativeDisplay, width, height);
            }
        }
Пример #3
0
        public static string GetOnPlayBehaviorName(int selectedIndex)
        {
            if (selectedIndex == 0)
            {
                return(Styles.gamePlayNormalContent.text);
            }
            if (selectedIndex == 1)
            {
                return(Styles.gamePlayMaximizedContent.text);
            }

            int displayIdx       = SelectedIndexToDisplayIndex(selectedIndex);
            var connectedDisplay = EditorFullscreenController.GetConnectedDisplayNames();

            var displayName = (displayIdx >= connectedDisplay.Length)
                ? "Invalid monitor"
                : connectedDisplay[displayIdx];

            return(Styles.gamePlayFullscreenContent.text + displayIdx + ":" + displayName);
        }
        static internal void SetStopmodeLayout()
        {
            if (m_PlayModeViewList != null && m_PlayModeViewList.Count > 0)
            {
                var monitorNames = EditorFullscreenController.GetConnectedDisplayNames();
                foreach (var playModeView in m_PlayModeViewList)
                {
                    if (playModeView.fullscreenMonitorIdx >= monitorNames.Length)
                    {
                        continue;
                    }

                    EditorFullscreenController.SetSettingsForCurrentDisplay(playModeView.fullscreenMonitorIdx);
                    EditorFullscreenController.OnExitPlaymode();
                }

                m_PlayModeViewList.Clear();
                m_PlayModeViewList = null;
            }

            WindowLayout.ShowAppropriateViewOnEnterExitPlaymode(false);
            Toolbar.RepaintToolbar();
        }
        static internal void InitPlaymodeLayout()
        {
            InitializePlaymodeViewList();
            WindowLayout.ShowAppropriateViewOnEnterExitPlaymodeList(true, out m_PlayModeViewList);

            var fullscreenDetected = false;
            var monitorNames       = EditorFullscreenController.GetConnectedDisplayNames();

            foreach (var playModeView in m_PlayModeViewList)
            {
                if (playModeView == null)
                {
                    continue;
                }

                if (playModeView.fullscreenMonitorIdx >= monitorNames.Length)
                {
                    continue;
                }

                if (playModeView.enterPlayModeBehavior == PlayModeView.EnterPlayModeBehavior.PlayFullscreen)
                {
                    EditorFullscreenController.SetSettingsForCurrentDisplay(playModeView.fullscreenMonitorIdx);
                    EditorFullscreenController.isFullscreenOnPlay           = true;
                    EditorFullscreenController.fullscreenDisplayId          = playModeView.fullscreenMonitorIdx;
                    EditorFullscreenController.isToolbarEnabledOnFullscreen = false;
                    EditorFullscreenController.targetDisplayID = playModeView.targetDisplay;

                    if (playModeView.m_Parent is DockArea dockArea && dockArea.actualView is GameView gv)
                    {
                        playModeView.m_Parent.EnableVSync(gv.vSyncEnabled);
                        EditorFullscreenController.enableVSync       = gv.vSyncEnabled;
                        EditorFullscreenController.selectedSizeIndex = gv.selectedSizeIndex;
                    }
                    fullscreenDetected = true;
                }
                else if (!fullscreenDetected)
                {
                    EditorFullscreenController.isFullscreenOnPlay = false;
                }

                if (playModeView.enterPlayModeBehavior == PlayModeView.EnterPlayModeBehavior.PlayMaximized)
                {
                    if (playModeView.m_Parent is DockArea dockArea)
                    {
                        m_MaximizePending = WindowLayout.MaximizePrepare(dockArea.actualView);
                        var gv = dockArea.actualView as GameView;
                        if (gv != null)
                        {
                            playModeView.m_Parent.EnableVSync(gv.vSyncEnabled);
                        }
                    }
                }

                EditorFullscreenController.OnEnterPlaymode();

                if (!EditorFullscreenController.isFullscreenOnPlay)
                {
                    playModeView.m_Parent.SetAsStartView();
                    playModeView.m_Parent.SetAsLastPlayModeView();

                    if (playModeView.maximized)
                    {
                        playModeView.m_Parent.Focus();
                    }

                    if (playModeView is IGameViewOnPlayMenuUser)
                    {
                        if (((IGameViewOnPlayMenuUser)playModeView).playFocused)
                        {
                            playModeView.m_Parent.Focus();
                        }
                    }
                }
                Toolbar.RepaintToolbar();
            }
        }