Exemplo n.º 1
0
        /// <summary>Returns a rect with the dimensions of the main screen.
        /// (Note that the position may not be right for multiple screen setups)</summary>
        public static Rect GetMainDisplayRect()
        {
            if (FullscreenUtility.IsWindows)
            {
                var mainDisplay = DisplayInfo
                                  .GetDisplays()
                                  .FirstOrDefault(d => d.PrimaryDisplay);

                if (mainDisplay != null)
                {
                    return(mainDisplay.DpiCorrectedArea);
                }

                Logger.Error("No main display??? This should not happen, falling back to Screen.currentResolution");
            }

            // Screen.currentResolution returns the resolution of the screen where
            // the currently focused window is located, not the main display resolution.
            // This caused the bug #53 on windows.
            // The same behaviour was not tested on Linux as macOS
            return(new Rect(0f, 0f, Screen.currentResolution.width, Screen.currentResolution.height));
        }
Exemplo n.º 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);
            }
        }