internal void OpenView(Rect rect, ScriptableObject view) { if (!view) { throw new ArgumentNullException("view"); } view.EnsureOfType(Types.View); if (FullscreenUtility.IsLinux) { throw new PlatformNotSupportedException("Linux does not support fullscreen from View class"); } if (Fullscreen.GetFullscreenFromView(view)) { Logger.Debug("Tried to fullscreen a view already in fullscreen"); return; } BeforeOpening(); var placeholder = CreateInstance <PlaceholderWindow>(); m_src = new ViewPyramid(view); m_dst = CreateFullscreenViewPyramid(rect, placeholder); SwapViews(m_src.View, m_dst.View); Rect = rect; AfterOpening(); }
private static EditorWindow FindCandidateForFullscreen(Type type, EditorWindow mainCandidate = null) { if (type == null) { throw new ArgumentNullException("type"); } if (!type.IsOfType(typeof(EditorWindow))) { throw new ArgumentException("Invalid type, type must inherit from UnityEditor.EditorWindow", "type"); } if (mainCandidate && !mainCandidate.IsOfType(type)) { throw new ArgumentException("Main candidate type must match the type argument or be null", "mainCandidate"); } // if (mainCandidate && !Fullscreen.GetFullscreenFromView(mainCandidate)) if (mainCandidate) { return(mainCandidate); // Our candidate is not null and is not fullscreened either } return(Resources // Returns the first window of our type that is not in fullscreen .FindObjectsOfTypeAll(type) .Cast <EditorWindow>() .FirstOrDefault(window => !Fullscreen.GetFullscreenFromView(window))); }
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(); }
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; }
// This should not be a static method, as static has no this // However, the 'this' in the method is unreliable and should be casted before using private void OnGUI() { var _this = (object)this as SceneView; var vp = new ViewPyramid(_this); var shouldRender = Fullscreen.GetFullscreenFromView(vp.Container, false); // Render if this window is in fullscreen _this.camera.gameObject.SetActive(shouldRender); if (shouldRender) { patcher.InvokeOriginal(_this); // This possibly throws a ExitGUIException } else { CustomOnGUI(); } }
public static void BringWindowsAbove() { if (!FullscreenPreferences.KeepFullscreenBelow) { return; } var fullscreens = Fullscreen.GetAllFullscreen(); if (fullscreens.Length == 0) { return; } var methodName = "Internal_BringLiveAfterCreation"; var windows = GetAllContainerWindowsOrdered() .Where(w => !Fullscreen.GetFullscreenFromView(w)) .Where(w => { if (w.GetPropertyValue <int>("showMode") == (int)ShowMode.MainWindow) { return(false); // Main Window should be kept below everything } if (fullscreens.FirstOrDefault((f) => f.m_src.Container == w)) { return(false); // Keep other fullscreen containers below } return(true); }); foreach (var w in windows) { if (w.HasMethod(methodName, new Type[] { typeof(bool), typeof(bool), typeof(bool) })) { w.InvokeMethod(methodName, true, false, false); } else { w.InvokeMethod(methodName, true, false); } } }