static FullscreenPreferences() { var rectSourceTooltip = string.Empty; rectSourceTooltip += "Controls where Fullscreen views opens.\n\n"; rectSourceTooltip += "Main Screen: Fullscreen opens on the primary screen;\n\n"; rectSourceTooltip += "Window Display: Open on the display that the target window is located (Windows only);\n\n"; rectSourceTooltip += "At Mouse Position: Fullscreen opens on the screen where the mouse pointer is;\n\n"; rectSourceTooltip += "Span: Fullscreen spans across all screens (Windows only);\n\n"; rectSourceTooltip += "Custom Rect: Fullscreen opens on the given custom Rect."; ToolbarVisible = new PrefItem <bool>("Toolbar", false, "Toolbar Visible", "Show and hide the toolbar on the top of some windows, like the Game View and Scene View."); FullscreenOnPlayEnabled = new PrefItem <bool>("FullscreenOnPlay", false, "Fullscreen On Play", "Override the \"Maximize on Play\" option of the game view to \"Fullscreen on Play\""); RectSource = new PrefItem <RectSourceMode>("RectSource", RectSourceMode.AtMousePosition, "Rect Source", rectSourceTooltip); CustomRect = new PrefItem <Rect>("CustomRect", FullscreenRects.GetMainDisplayRect(), "Custom Rect", string.Empty); DisableNotifications = new PrefItem <bool>("DisableNotifications", false, "Disable Notifications", "Disable the notifications that shows up when opening a new fullscreen view."); KeepFullscreenBelow = new PrefItem <bool>("KeepFullscreenBelow", true, "Keep Utility Views Above", "Keep utility views on top of fullscreen views.\nThis is useful to integrate with assets that need to keep windows open, such as Peek by Ludiq."); DisableSceneViewRendering = new PrefItem <bool>("DisableSceneViewRendering", true, "Disable Scene View Rendering", "Increase Fullscreen Editor performance by not rendering SceneViews while there are open fullscreen views."); MosaicMapping = new PrefItem <int[]>("MosaicMapping", new [] { 0, 1, 2, 3, 4, 5, 6, 7 }, "Mosaic Screen Mapping", "Defines which display renders on each screen when using Mosaic."); onLoadDefaults += () => // Array won't revert automaticaly because it is changed as reference MosaicMapping.Value = new [] { 0, 1, 2, 3, 4, 5, 6, 7 }; if (FullscreenUtility.MenuItemHasShortcut(Shortcut.TOOLBAR_PATH)) { ToolbarVisible.Content.text += string.Format(" ({0})", FullscreenUtility.TextifyMenuItemShortcut(Shortcut.TOOLBAR_PATH)); } if (FullscreenUtility.MenuItemHasShortcut(Shortcut.FULLSCREEN_ON_PLAY_PATH)) { FullscreenOnPlayEnabled.Content.text += string.Format(" ({0})", FullscreenUtility.TextifyMenuItemShortcut(Shortcut.FULLSCREEN_ON_PLAY_PATH)); } }
protected override void AfterOpening() { base.AfterOpening(); Focus(); if (m_src.Window) { m_dst.Window.titleContent = m_src.Window.titleContent; // Copy the title of the window to the placeholder } SetToolbarStatus(FullscreenPreferences.ToolbarVisible); // Hide/show the toolbar // macOS doesn't like fast things, so we'll wait a bit and do it again After.Milliseconds(100d, () => SetToolbarStatus(FullscreenPreferences.ToolbarVisible)); var notificationWindow = ActualViewPyramid.Window; var menuItemPath = string.Empty; if (notificationWindow.IsOfType(Types.GameView)) { menuItemPath = Shortcut.GAME_VIEW_PATH; } else if (notificationWindow is SceneView) { menuItemPath = Shortcut.SCENE_VIEW_PATH; } else { menuItemPath = Shortcut.CURRENT_VIEW_PATH; } FullscreenUtility.ShowFullscreenExitNotification(notificationWindow, menuItemPath); }
/// <summary>Focus the view of this fullscreen.</summary> public virtual void Focus() { if (FullscreenedView && FullscreenedView.IsOfType(Types.GUIView)) { FullscreenUtility.FocusView(FullscreenedView); } }
private static void OverrideMaximizeOnPlay() { After.Frames(1, () => { // Call after one frame, so we don't acess the styles class before it's created var stylesClass = Types.GameView.GetNestedType("Styles", ReflectionUtility.FULL_BINDING); var currentContent = stylesClass.GetFieldValue <GUIContent>("maximizeOnPlayContent"); var newContent = new GUIContent("Fullscreen on Play", FullscreenUtility.FullscreenOnPlayIcon); var originalContent = new GUIContent(currentContent); var overrideEnabled = FullscreenPreferences.FullscreenOnPlayEnabled; currentContent.text = overrideEnabled ? newContent.text : originalContent.text; currentContent.image = overrideEnabled ? newContent.image : originalContent.image; currentContent.tooltip = overrideEnabled ? newContent.tooltip : originalContent.tooltip; FullscreenPreferences.FullscreenOnPlayEnabled.OnValueSaved += v => { currentContent.text = v ? newContent.text : originalContent.text; currentContent.image = v ? newContent.image : originalContent.image; currentContent.tooltip = v ? newContent.tooltip : originalContent.tooltip; if (FullscreenUtility.GetMainGameView()) { FullscreenUtility.GetMainGameView().SetPropertyValue("maximizeOnPlay", v); } }; }); }
public static void UpdateGlobalToolbarStatus() { if (FullscreenPreferences.UseGlobalToolbarHiding) { FullscreenUtility.SetToolbarHeight(GlobalToolbarShouldBeHidden ? 0f : defaultToolbarHeight); } }
private static void MVMenuItem() { var mainView = FullscreenUtility.GetMainView(); if (FullscreenUtility.IsLinux) { if (wmctrl.IsInstalled) { wmctrl.ToggleNativeFullscreen(mainView); } else { Logger.Warning("wmctrl not installed, cannot fullscreen main view. Install it using 'sudo apt-get install wmctrl'"); } return; } if (!mainView) { Logger.Error("No Main View found, this should not happen"); return; } Fullscreen.ToggleFullscreen(mainView); }
static FullscreenPreferences() { var rectSourceTooltip = string.Empty; rectSourceTooltip += "Controls where Fullscreen views opens.\n\n"; rectSourceTooltip += "Main Screen: Fullscreen opens on the primary screen;\n\n"; rectSourceTooltip += "Window Display: Open on the display that the target window is located (Windows only);\n\n"; rectSourceTooltip += "At Mouse Position: Fullscreen opens on the screen where the mouse pointer is;\n\n"; rectSourceTooltip += "Span: Fullscreen spans across all screens (Windows only);\n\n"; rectSourceTooltip += "Custom Rect: Fullscreen opens on the given custom Rect."; ToolbarVisible = new PrefItem <bool>("Toolbar", false, "Toolbar Visible", "Show and hide the toolbar on the top of some windows, like the Game View and Scene View."); FullscreenOnPlayEnabled = new PrefItem <bool>("FullscreenOnPlay", false, "Fullscreen On Play", "Override the \"Maximize on Play\" option of the game view to \"Fullscreen on Play\""); RectSource = new PrefItem <RectSourceMode>("RectSource", RectSourceMode.AtMousePosition, "Rect Source", rectSourceTooltip); CustomRect = new PrefItem <Rect>("CustomRect", FullscreenRects.GetMainDisplayRect(), "Custom Rect", string.Empty); DisableNotifications = new PrefItem <bool>("DisableNotifications", false, "Disable Notifications", "Disable the notifications that shows up when opening a new fullscreen view."); if (FullscreenUtility.MenuItemHasShortcut(Shortcut.TOOLBAR_PATH)) { ToolbarVisible.Content.text += string.Format(" ({0})", FullscreenUtility.TextifyMenuItemShortcut(Shortcut.TOOLBAR_PATH)); } if (FullscreenUtility.MenuItemHasShortcut(Shortcut.FULLSCREEN_ON_PLAY_PATH)) { FullscreenOnPlayEnabled.Content.text += string.Format(" ({0})", FullscreenUtility.TextifyMenuItemShortcut(Shortcut.FULLSCREEN_ON_PLAY_PATH)); } }
private static void MVMenuItem() { var mainView = FullscreenUtility.GetMainView(); if (!mainView) { return; // This should never happen } Fullscreen.ToggleFullscreen(mainView); }
internal void OpenWindow(Rect rect, Type type, EditorWindow window = null, bool disposableWindow = false) { if (type == null) { throw new ArgumentNullException("type"); } if (!type.IsOfType(typeof(EditorWindow))) { throw new ArgumentException("Type must be inherited from UnityEditor.EditorWindow", "type"); } if (window is PlaceholderWindow) { FullscreenUtility.ShowFullscreenNotification(window, "Wanna fullscreen the placeholder?\nSorry, not possible"); Logger.Debug("Tried to fullscreen a placeholder window"); return; } if (Fullscreen.GetFullscreenFromView(window)) { FullscreenUtility.ShowFullscreenNotification(window, "You can't fullscreen a window already in fullscreen"); Logger.Debug("Tried to fullscreen a view already in fullscreen"); return; } BeforeOpening(); if (window) { m_src = new ViewPyramid(window); } var childWindow = window ? (EditorWindow)CreateInstance <PlaceholderWindow>() : (EditorWindow)CreateInstance(type); // Instantiate a new window for this fullscreen m_dst = CreateFullscreenViewPyramid(rect, childWindow); if (window) // We can't swap the src window if we didn't create a placeholder window { SwapWindows(m_src.Window, m_dst.Window); } Rect = rect; if (disposableWindow && childWindow is PlaceholderWindow) { childWindow.Close(); // Close the pyramid we created because disposable views are not restore later m_dst.Window = m_src.Window; } AfterOpening(); }
public static void UpdateGameViewArea(FullscreenContainer fs) { After.Frames(50, () => { var window = fs.ActualViewPyramid.Window; if (window && window.IsOfType(Types.PlayModeView)) { Logger.Debug("Fixing game view area"); FullscreenUtility.FocusView(FullscreenUtility.GetMainView()); // Issue #95, fix Input.mouseScrollDelta window.Focus(); } }); }
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; }
protected override void AfterOpening() { base.AfterOpening(); Focus(); if (m_src.Window) { m_dst.Window.titleContent = m_src.Window.titleContent; // Copy the title of the window to the placeholder } SetToolbarStatus(FullscreenPreferences.ToolbarVisible); // Hide/show the toolbar // macOS doesn't like fast things, so we'll wait a bit and do it again // Looks like Linux does not like it too After.Milliseconds(100d, () => SetToolbarStatus(FullscreenPreferences.ToolbarVisible)); var notificationWindow = ActualViewPyramid.Window; After.Milliseconds(50d, () => { if (!notificationWindow) // Might have been closed { return; } var menuItemPath = string.Empty; if (notificationWindow.IsOfType(Types.GameView)) { menuItemPath = Fullscreen .GetAllFullscreen() .Where(fs => fs.ActualViewPyramid.Window && fs.ActualViewPyramid.Window.IsOfType(Types.GameView)) .Count() > 1 ? Shortcut.MOSAIC_PATH : Shortcut.GAME_VIEW_PATH; } else if (notificationWindow is SceneView) { menuItemPath = Shortcut.SCENE_VIEW_PATH; } else { menuItemPath = Shortcut.CURRENT_VIEW_PATH; } FullscreenUtility.ShowFullscreenExitNotification(notificationWindow, menuItemPath); }); }
private static void MVMenuItem() { var mainView = FullscreenUtility.GetMainView(); if (FullscreenUtility.IsLinux) { wmctrl.ToggleNativeFullscreen(mainView); return; } if (!mainView) { Logger.Error("No Main View found, this should not happen"); return; } Fullscreen.ToggleFullscreen(mainView); }
private static void CVMenuItem() { var focusedView = FullscreenUtility.GetFocusedViewOrWindow(); if (!focusedView) { return; } if (focusedView is EditorWindow) { Fullscreen.ToggleFullscreen(focusedView as EditorWindow); } else { Fullscreen.ToggleFullscreen(focusedView); } }
private static void CVMenuItem() { var focusedView = FullscreenUtility.IsLinux ? EditorWindow.focusedWindow : // Linux does not support View fullscreen, only EditorWindow FullscreenUtility.GetFocusedViewOrWindow(); if (!focusedView || focusedView is PlaceholderWindow) { return; } if (focusedView is EditorWindow) { Fullscreen.ToggleFullscreen(focusedView as EditorWindow); } else { Fullscreen.ToggleFullscreen(focusedView); } }
static GlobalToolbarHiding() { defaultToolbarHeight = FullscreenUtility.GetToolbarHeight(); FullscreenPreferences.UseGlobalToolbarHiding.OnValueSaved += v => { if (!v) { FullscreenUtility.SetToolbarHeight(defaultToolbarHeight); } }; FullscreenPreferences.ToolbarVisible.OnValueSaved += v => UpdateGlobalToolbarStatus(); UpdateGlobalToolbarStatus(); After.Frames(2, () => // Why? IDK UpdateGlobalToolbarStatus() ); FullscreenCallbacks.afterFullscreenClose += fs => UpdateGlobalToolbarStatus(); FullscreenCallbacks.afterFullscreenOpen += fs => UpdateGlobalToolbarStatus(); }
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); } }
/// <summary>Gets wheter the view of this fullscreen is focused or not.</summary> public virtual bool IsFocused() { return(FullscreenUtility.IsViewFocused(FullscreenedView)); }
private static void GVMenuItem() { var gameView = FindCandidateForFullscreen(Types.GameView, FullscreenUtility.GetMainGameView()); Fullscreen.ToggleFullscreen(Types.GameView, gameView); }