示例#1
0
        private static void SetIsPlaying(bool playing)
        {
            var fullscreens = Fullscreen.GetAllFullscreen()
                              .Select(fullscreen => fullscreen as FullscreenWindow)
                              .Where(fullscreen => fullscreen);

            // We close all the game views created on play, even if the option was disabled in the middle of the play mode
            // This is done to best reproduce the default behaviour of the maximize on play
            if (!playing)
            {
                foreach (var fs in fullscreens)
                {
                    if (fs && fs.CreatedByFullscreenOnPlay) // fs might have been destroyed
                    {
                        fs.Close();
                    }
                }
                return;
            }

            if (!FullscreenPreferences.FullscreenOnPlayEnabled)
            {
                return; // Nothing to do here
            }
            var gameView = FullscreenUtility
                           .GetGameViews()
                           .FirstOrDefault(gv => gv && gv.GetPropertyValue <bool>("maximizeOnPlay"));

            if (!gameView && FullscreenUtility.GetGameViews().Length > 0)
            {
                return;
            }

            foreach (var fs in fullscreens)
            {
                if (fs && fs.Rect.Overlaps(gameView.position)) // fs might have been destroyed
                {
                    return;                                    // We have an open fullscreen where the new one would be, so let it there
                }
            }
            if (gameView && Fullscreen.GetFullscreenFromView(gameView))
            {
                return; // The gameview is already in fullscreen
            }
            var gvfs = Fullscreen.MakeFullscreen(Types.GameView, gameView);
            gvfs.CreatedByFullscreenOnPlay = true;
        }
示例#2
0
        private static void MosaicMenuItem()
        {
            var openFullscreens = Fullscreen.GetAllFullscreen();

            if (openFullscreens.Length > 0)
            {
                foreach (var fs in openFullscreens)
                {
                    fs.Close();
                }
                return;
            }

            var displays = DisplayInfo
                           .GetDisplays()
                           .Where(d => (d.displayDevice.StateFlags & DisplayDeviceStateFlags.AttachedToDesktop) != 0)
                           .ToList();

            for (var i = 0; i < displays.Count && i < 8; i++)
            {
                var candidate = FindCandidateForFullscreen(Types.GameView, FullscreenUtility.GetMainGameView());

                if (candidate)
                {
                    candidate = EditorWindow.Instantiate(candidate);
                    candidate.Show();
                }

                var fs            = Fullscreen.MakeFullscreen(Types.GameView, candidate, true);
                var gameView      = fs.ActualViewPyramid.Window;
                var targetDisplay = FullscreenPreferences.MosaicMapping.Value[i];

                fs.Rect = displays[i].DpiCorrectedArea;
                FullscreenUtility.SetGameViewDisplayTarget(gameView, targetDisplay);
            }
        }