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); } }; }); }
/// <summary>Method that will be called after the creation of the ContainerWindow for this fullscreen.</summary> protected virtual void AfterOpening() { After.Frames(2, () => UnityEditorInternal.InternalEditorUtility.RepaintAllViews()); Logger.Debug(this, "{6}\n\nSRC\nWindow: {0}\nView: {1}\nContainer: {2}\n\nDST\nWindow: {3}\nView: {4}\nContainer: {5}\n", m_src.Window, m_src.View, m_src.Container, m_dst.Window, m_dst.View, m_dst.Container, name ); }
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 OpenPreferences() { #if UNITY_2018_3_OR_NEWER var windowType = ReflectionUtility.FindClass("UnityEditor.SettingsWindow"); windowType.InvokeMethod("Show", SettingsScope.User, "Preferences/Fullscreen Editor"); #else var windowType = ReflectionUtility.FindClass("UnityEditor.PreferencesWindow"); windowType.InvokeMethod("ShowPreferencesWindow"); After.Frames(3, () => { var window = EditorWindow.GetWindow(windowType); var sections = window.GetFieldValue <IList>("m_Sections").Cast <object>().ToList(); var index = sections.FindIndex(section => section.GetFieldValue <GUIContent>("content").text == "Fullscreen"); window.SetPropertyValue("selectedSectionIndex", index); }); #endif }
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(); }
/// <summary>Method that will be called after the creation of the ContainerWindow for this fullscreen.</summary> protected virtual void AfterOpening() { After.Frames(2, () => { UnityEditorInternal.InternalEditorUtility.RepaintAllViews(); didPresent.Invoke(); didPresent = null; }); Logger.Debug(this, "{6}\n\nSRC\nWindow: {0}\nView: {1}\nContainer: {2}\n\nDST\nWindow: {3}\nView: {4}\nContainer: {5}\n", m_src.Window, m_src.View, m_src.Container, m_dst.Window, m_dst.View, m_dst.Container, name ); FullscreenCallbacks.afterFullscreenOpen(this); }
protected virtual void OnEnable() { if (m_ourIndex == -1) { m_ourIndex = CurrentIndex++; name = string.Format("Fullscreen #{0}", m_ourIndex); hideFlags = HideFlags.HideAndDontSave; } #if UNITY_2018_1_OR_NEWER EditorApplication.wantsToQuit += WantsToQuit; #endif if (m_old && !m_dst.Container) { Logger.Warning("{0} wasn't properly closed", name); // After 1 frame to prevent OnDisable and OnDestroy from being called before this methods returns After.Frames(1, () => DestroyImmediate(this, true)); } m_old = true; }