示例#1
0
        private static string GetMenuItemScript(string label, string methodName, EditorFullscreenSettings.FullscreenOption fullscreenOptions)
        {
            string hotkeyString = EditorInput.GetKeyMenuItemString(fullscreenOptions.hotkey, fullscreenOptions.modifiers);
            string script       = "        [MenuItem(" + typeof(EditorFullscreenSettings).Name + ".MENU_ITEM_PATH + \"" + label + " " + hotkeyString + "\")]\r\n"
                                  + "        public static void " + methodName + "() {EditorFullscreenController." + methodName + "();}\r\n";

            return(script);
        }
        private static string GetMenuItemScript(string label, string methodName, EditorFullscreenSettings.FullscreenOption fullscreenOptions, string fullscreenHotkey)
        {
            string hotkeyString = " _" + EditorInput.GetKeyMenuItemString(fullscreenOptions.hotkey, fullscreenOptions.modifiers);

#if UNITY_STANDALONE_WIN && (UNITY_5_0 || UNITY_5_1)
            //Disable menu-item hotkeys for Unity pre-5.4 because of strange bugs which occur when they have no modifier. Instead the hotkeys are handled through EditorInput.
            hotkeyString = "";
            label       += char.ConvertFromUtf32(9) + EditorInput.GetKeysDownString(fullscreenOptions.hotkey, fullscreenOptions.modifiers);
#endif

            string fullscreenOpsString = "EditorFullscreenSettings.settings." + fullscreenHotkey;
            string methodCall          = "EditorFullscreenController.TriggerFullscreenHotkey(" + fullscreenOpsString + ");";

            string script = "        [MenuItem(" + typeof(EditorFullscreenSettings).Name + ".MENU_ITEM_PATH + \"" + label + hotkeyString + "\")]\r\n"
                            + "        public static void " + methodName + "() {" + methodCall + "}\r\n";
            return(script);
        }
示例#3
0
        void OnGUI()
        {
            hotkeyWasSet = false;
            hotkeyInputFields.Clear();
            hotkeyID = 0;
            var style       = new GUIStyle();
            var buttonStyle = new GUIStyle();
            var smallIndent = new GUIStyle();

            style.margin.left       = 20;
            style.margin.right      = 20;
            smallIndent.margin.left = 3;

            //Toolbar
            EditorGUILayout.BeginVertical(style);
            var headerToolbarStyle = new GUIStyle(GUI.skin.button);

            headerToolbarStyle.fontSize         = 15;
            headerToolbarStyle.fontStyle        = FontStyle.Bold;
            headerToolbarStyle.normal.textColor = EditorGUIUtility.isProSkin ? proHeadingColor : new Color(0.25f, 0.25f, 0.25f, 1f);
            headerToolbarStyle.margin.top       = 10;
            headerToolbarStyle.margin.bottom    = 5;
            string[] toolbarItems = { "Fullscreen Options", "Game Window Options" };

            EditorGUI.BeginChangeCheck();
            selectedToolbarItem = GUILayout.Toolbar(selectedToolbarItem, toolbarItems, headerToolbarStyle, GUILayout.Height(32));
            guiVisibilityChange = EditorGUI.EndChangeCheck() || guiVisibilityChange;

            EditorGUILayout.EndVertical();

            //Page header
            EditorGUILayout.BeginVertical(style);
            EditorGUILayout.BeginHorizontal();
            EditorGUIUtility.labelWidth = 245f;
            GUILayout.Label(toolbarItems[selectedToolbarItem], headerStyle, new GUILayoutOption[0]);

            //Reset to defaults button
            buttonStyle              = new GUIStyle(GUI.skin.button);
            buttonStyle.fontSize     = 10;
            buttonStyle.fontStyle    = FontStyle.Bold;
            buttonStyle.padding      = new RectOffset(0, 0, 5, 5);
            buttonStyle.margin.top   = 10;
            buttonStyle.margin.right = 24;
            if (GUILayout.Button(new GUIContent("Reset to Defaults", "Reset all settings to their default values."), buttonStyle, GUILayout.MaxWidth(200)))
            {
                ResetSettingsToDefaults();
                Repaint();
                return;
            }
            EditorGUILayout.EndHorizontal();

            //Indent
            EditorGUILayout.BeginVertical(style);

            //Debugging checkbox
            EditorGUILayout.BeginHorizontal();
            var s = new GUIStyle(GUI.skin.toggle);

            s.alignment                 = TextAnchor.LowerRight;
            s.normal.textColor          = EditorStyles.label.normal.textColor;
            s.padding.top               = -5;
            s.margin.top                = -5;
            EditorGUIUtility.labelWidth = 0.1f;

            GUILayout.FlexibleSpace();
            var dbStyle = new GUIStyle();

            dbStyle.fontSize         = 9;
            dbStyle.normal.textColor = EditorStyles.label.normal.textColor;
            dbStyle.alignment        = TextAnchor.LowerRight;
            dbStyle.fixedHeight      = 15f;
            GUILayout.Label("Debugging", dbStyle, new GUILayoutOption[0]);
            settings.debugModeEnabled = EditorGUILayout.Toggle(new GUIContent(" ", "Enables debug mode"), settings.debugModeEnabled, s);

            EditorGUILayout.EndHorizontal();
            GUILayout.Space(-10);

            if (selectedToolbarItem == 0)
            {
                //Fullscreen Window Hotkeys
                EditorGUIUtility.labelWidth = 175f;
                GUILayout.Label("Fullscreen Window Hotkeys", subHeaderStyle, new GUILayoutOption[0]);
                EditorGUILayout.BeginVertical(smallIndent);
#if UNITY_EDITOR_OSX
                bool showToolbarOptionForMainUnityWindow = false; //Toolbar option isn't necessary for main window on Mac (toolbar can be toggled by moving the mouse to the top of the screen).
#else
                bool showToolbarOptionForMainUnityWindow = true;
#endif
                AddFullscreenOption(ref settings.mainUnityWindow, "Main Unity Window", true, showToolbarOptionForMainUnityWindow);
                AddFullscreenOption(ref settings.sceneWindow, "Scene Window", true, true);
                AddFullscreenOption(ref settings.gameWindow, GAME_WINDOW_LABEL, true, true, true);
                AddFullscreenOption(ref settings.currentlyFocusedWindow, "Currently Focused Window", true, true);
                AddFullscreenOption(ref settings.windowUnderCursor, "Window Under Cursor", true, true);
                EditorGUILayout.EndVertical();

                //Other Hotkeys
                GUILayout.Label("Other Options", subHeaderStyle, new GUILayoutOption[0]);
                EditorGUILayout.BeginVertical(smallIndent);
                AddFullscreenOption(ref settings.toggleTopToolbar, "Show/Hide Top Toolbar", false, false);
                EditorGUILayout.EndVertical();
                style            = new GUIStyle(smallIndent);
                style.margin.top = 8;
                EditorGUILayout.BeginVertical(style);
                AddFullscreenOption(ref settings.closeAllFullscreenWindows, "Close All Fullscreen Windows", false, false);
                EditorGUILayout.EndVertical();

                EditorGUILayout.BeginVertical(style);
                EditorGUILayout.BeginHorizontal();

                EditorGUIUtility.labelWidth = 255f;
                var label = new GUIContent("Show a Notification on Fullscreen Entry", "Show a notification when entering fullscreen.");
                style = new GUIStyle(smallHeadingStyle);

                GUILayout.Label(label, style, new GUILayoutOption[0]);

                style           = new GUIStyle();
                style.alignment = TextAnchor.LowerRight;
                EditorGUILayout.BeginHorizontal(new[] { GUILayout.MaxWidth(160f) });
                settings.fullscreenNotification = EditorGUILayout.Toggle(settings.fullscreenNotification, new GUILayoutOption[0]);
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.EndHorizontal();
                EditorGUILayout.EndVertical();
            }
            else if (selectedToolbarItem == 1)
            {
                //Game Window Fullscreen Options
                EditorGUIUtility.labelWidth = 255f;
                GUILayout.Label("Game Start/Stop", subHeaderStyle, new GUILayoutOption[0]);
                EditorGUILayout.BeginVertical(smallIndent);

                var label = new GUIContent("Start the Game When Entering Fullscreen", "Start the game when entering a fullscreen game window.");
                settings.startGameWhenEnteringFullscreen = EditorGUILayout.Toggle(label, settings.startGameWhenEnteringFullscreen, new GUILayoutOption[0]);

                label = new GUIContent("Stop the Game When Exiting Fullscreen", "Stop the game when exiting fullscreen game window.");
                settings.stopGameWhenExitingFullscreen = (EditorFullscreenSettings.StopGameWhenExitingFullscreen)EditorGUILayout.EnumPopup(label, settings.stopGameWhenExitingFullscreen, new GUILayoutOption[0]);

                label = new GUIContent("Close Fullscreen On Game Stop", "Close fullscreen game window/s when the game stops.");
                settings.closeFullscreenOnGameStop = (EditorFullscreenSettings.CloseFullscreenOnGameStop)EditorGUILayout.EnumPopup(label, settings.closeFullscreenOnGameStop, new GUILayoutOption[0]);

                GUILayout.Label("Framerate", subHeaderStyle, new GUILayoutOption[0]);
                label = new GUIContent("To Improve FPS When Entering Fullscreen", "Multiple visible game views can significantly affect the performance/FPS of the game. Choose an option to prevent this from happening.");
                settings.improveFpsOptions = (EditorFullscreenSettings.ImproveFPSOptions)EditorGUILayout.EnumPopup(label, settings.improveFpsOptions, new GUILayoutOption[0]);

                //Custom Fullscreen Game Views
                GUILayout.Label("Custom Fullscreen Game Views", subHeaderStyle, new GUILayoutOption[0]);

                EditorGUIUtility.labelWidth = 184f;
                customGameViewsScrollPos    = EditorGUILayout.BeginScrollView(customGameViewsScrollPos, false, true, GUIStyle.none, GUI.skin.verticalScrollbar, GUIStyle.none, new GUILayoutOption[0]);
                var groupVertStyle = new GUIStyle();
                groupVertStyle.padding.right = 20;
                groupVertStyle.margin.right  = 5;
                EditorGUILayout.BeginVertical(groupVertStyle, GUILayout.MinHeight(360));

#if UNITY_2019_1_OR_NEWER
                var foldoutStyle = new GUIStyle(EditorStyles.foldoutHeader);
                foldoutStyle.margin.bottom = 5;
                foldoutStyle.margin.top    = 15;
#else
                var foldoutStyle = new GUIStyle(EditorStyles.foldout);
                foldoutStyle.fontStyle = FontStyle.Bold;
                var dropLineStyle = new GUIStyle();
                dropLineStyle.margin.top    = 10;
                dropLineStyle.margin.bottom = 0;
                var indentStyle = new GUIStyle();
                indentStyle.margin.left = 12;
                var popupStyle = GUI.skin.FindStyle("IconButton");
                var popupIcon  = EditorGUIUtility.IconContent("_Popup");
#endif

                var allGameWins = settings.AllGameWindows;
                for (int i = 0; i < allGameWins.Count; i++)
                {
                    if (foldoutCustomGameWindowSettings.Count < (i + 1))
                    {
                        foldoutCustomGameWindowSettings.Add(i == 0 ? true : false);
                    }
                    var fullscreenOption = allGameWins[i];

                    EditorGUI.BeginChangeCheck();
#if UNITY_2019_1_OR_NEWER
                    foldoutCustomGameWindowSettings[i] = EditorGUILayout.BeginFoldoutHeaderGroup(foldoutCustomGameWindowSettings[i], fullscreenOption.optionLabel + (i == 0 || fullscreenOption.optionLabel != "Game Window" ? "" : " " + (i + 1)), foldoutStyle, menuPos => ShowGameWindowFoldoutMenu(menuPos, i));
                    guiVisibilityChange = EditorGUI.EndChangeCheck() || guiVisibilityChange;
                    if (foldoutCustomGameWindowSettings[i])
                    {
                        AddFullscreenOption(ref fullscreenOption, null, true, true);
                    }
                    EditorGUILayout.EndFoldoutHeaderGroup();
#else
                    EditorGUILayout.BeginHorizontal(dropLineStyle);
                    foldoutCustomGameWindowSettings[i] = EditorGUILayout.Foldout(foldoutCustomGameWindowSettings[i], fullscreenOption.optionLabel + (i == 0 || fullscreenOption.optionLabel != "Game Window" ? "" : " " + (i + 1)), true, foldoutStyle);
                    var foldoutRect = EditorGUILayout.GetControlRect(false, 20f, GUILayout.MaxWidth(20f));
                    EditorGUILayout.EndHorizontal();
                    guiVisibilityChange = EditorGUI.EndChangeCheck() || guiVisibilityChange;
                    if (popupStyle == null)
                    {
                        popupStyle = EditorStyles.popup;
                    }

                    if (GUI.Button(foldoutRect, popupIcon, popupStyle))
                    {
                        ShowGameWindowFoldoutMenu(foldoutRect, i);
                    }
                    EditorGUILayout.BeginVertical(indentStyle);
                    if (foldoutCustomGameWindowSettings[i])
                    {
                        AddFullscreenOption(ref fullscreenOption, null, true, true);
                    }
                    EditorGUILayout.EndVertical();
#endif
                }

                EditorGUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();
                buttonStyle            = new GUIStyle(GUI.skin.button);
                buttonStyle.fontSize   = 12;
                buttonStyle.padding    = new RectOffset(10, 10, 4, 4);
                buttonStyle.margin.top = 12;
                if (GUILayout.Button(new GUIContent("Add Game View", "Add a custom game view with its own settings and hotkey."), buttonStyle, GUILayout.MaxWidth(250)))
                {
                    //Add a Game View
                    if (settings.customWindows == null)
                    {
                        settings.customWindows = new List <EditorFullscreenSettings.FullscreenOption>();
                    }
                    var fullscreenOption = new EditorFullscreenSettings.FullscreenOption(settings, true);
                    fullscreenOption.windowTypeAssemblyQualifiedName = EditorFullscreenState.GameViewType.AssemblyQualifiedName;
                    fullscreenOption.optionLabel     = "Game Window";
                    fullscreenOption.openAtPosition  = EditorFullscreenSettings.OpenFullscreenAtPosition.AtSpecifiedPosition;
                    fullscreenOption.gameViewOptions = new EditorFullscreenSettings.GameViewOptions();
                    fullscreenOption.isGameView      = true;
                    settings.customWindows.Add(fullscreenOption);
                    foldoutCustomGameWindowSettings.Add(true);
                }
                buttonStyle.alignment = TextAnchor.LowerCenter;
                GUILayout.FlexibleSpace();
                EditorGUILayout.EndHorizontal(); //End Add Game View button horizontal
                EditorGUILayout.EndVertical();   //End Add Game View vertical scroll area
                EditorGUILayout.EndScrollView();

                EditorGUILayout.EndVertical();
            }

            if ((GUI.changed && !guiVisibilityChange) || hotkeyWasSet || customGameViewWasChanged)
            {
                if (hotkeyWasSet)
                {
                    hotkeysWereChanged = true;
                }
                allowApplySettings = true;
                if (customGameViewWasChanged)
                {
                    customGameViewWasChanged = false;
                }
            }
            if (guiVisibilityChange)
            {
                guiVisibilityChange = false;
            }

            GUILayout.FlexibleSpace();
            EditorGUILayout.BeginVertical();

            var lineStyle = new GUIStyle();
            lineStyle.margin.top = 10;
            EditorGUILayout.BeginHorizontal(lineStyle);
            try
            {
                var linkLabel = typeof(EditorGUILayout).GetMethod("LinkLabel", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static, null, new System.Type[] { typeof(GUIContent), typeof(GUILayoutOption[]) }, null);
                if (settings.fullscreenedCount > 19 && settings.clickedLeaveRevCount < 3 && (settings.clickedLeaveRevCount < 1 || settings.settingsClosedAfterRevCount < SETTINGS_CLOSED_AFTER_REV_CHECK_LIMIT))
                {
                    var msgStyle = new GUIStyle();
                    msgStyle.fontStyle    = FontStyle.Normal;
                    msgStyle.margin.top   = 2;
                    msgStyle.margin.right = 0;
                    if (EditorGUIUtility.isProSkin)
                    {
                        msgStyle.normal.textColor = new Color(0.75f, 0.75f, 0.75f, 1f);
                    }
                    lineStyle = new GUIStyle();
                    lineStyle.margin.right = 6;
                    EditorGUILayout.EndHorizontal();
                    EditorGUILayout.BeginHorizontal(lineStyle);
                    GUILayout.FlexibleSpace();
                    GUILayout.Label("Thanks for using this extension!", msgStyle, new GUILayoutOption[0]);
                    lineStyle = new GUIStyle();
                    lineStyle.margin.bottom = 10;
                    EditorGUILayout.EndHorizontal();
                    EditorGUILayout.BeginHorizontal(lineStyle);
                    GUILayout.FlexibleSpace();
                    var msgStyle2 = new GUIStyle(msgStyle);
                    #if UNITY_EDITOR_WIN && UNITY_2019_3_OR_NEWER
                    msgStyle2.margin.top = 5;
                    #endif
                    GUILayout.Label("If you find it useful, please consider", msgStyle2, new GUILayoutOption[] {
                    #if UNITY_EDITOR_OSX
                        GUILayout.MaxWidth(188f)
                    #else
                    #if UNITY_2019_3_OR_NEWER
                        GUILayout.MaxWidth(203f)
                    #else
                        GUILayout.MaxWidth(200f)
                    #endif
                    #endif
                    });
                    var leaveRevClicked = (bool)linkLabel.Invoke(null, new object[] { new GUIContent("giving us a review."), new GUILayoutOption[] { } });
                    if (leaveRevClicked)
                    {
                        Application.OpenURL("https://assetstore.unity.com/packages/tools/utilities/editor-window-fullscreen-85477");
                        settings.clickedLeaveRevCount++;
                        EditorFullscreenSettings.settings.clickedLeaveRevCount++;
                        EditorFullscreenSettings.settings.SaveSettings(false);
                    }
                    EditorGUILayout.EndHorizontal();
                    EditorGUILayout.BeginHorizontal();
                }
示例#4
0
        private static string GetMenuItemScript(string label, int tabsInLabel, string methodName, EditorFullscreenSettings.FullscreenOption fullscreenOptions, string fullscreenHotkey, int menuPriority)
        {
            if (fullscreenOptions.hotkey == KeyCode.None)
            {
                return("");                                          //Blank hotkey, so no script required.
            }
            string hotkeyString = " " + EditorInput.GetKeyMenuItemString(fullscreenOptions.hotkey, fullscreenOptions.modifiers);

#if UNITY_EDITOR_OSX
            //Add extra label on macOS for F hotkeys (F hotkeys are labeled incorrectly with modifiers, and some other hotkeys show no label)
            for (int i = 0; i < tabsInLabel; i++)
            {
                label += char.ConvertFromUtf32(9);
            }
            label += EditorInput.GetKeysDownString(fullscreenOptions.hotkey, fullscreenOptions.modifiers);
#endif

            string fullscreenOpsString = "EditorFullscreenSettings.settings." + fullscreenHotkey;
            string methodCall          = "EditorFullscreenController.TriggerFullscreenHotkey(" + fullscreenOpsString + ");";

            string script = "        [MenuItem(" + typeof(EditorFullscreenSettings).Name + ".MENU_ITEM_PATH + \"" + label + hotkeyString + "\", false, " + menuPriority + ")]\r\n"
                            + "        public static void " + methodName + "() {" + methodCall + "}\r\n";
            return(script);
        }
        private static bool CheckHotkeyTriggered(KeyCode keyCode, EventModifiers modifiers, EditorFullscreenSettings.FullscreenOption fullscreenOption)
        {
            var keyString = keyCode.ToKeyString();

            if (keyCode == fullscreenOption.hotkey)
            {
                if (modifiers.MatchesFlag(EventModifiers.FunctionKey) != fullscreenOption.modifiers.MatchesFlag(EventModifiers.FunctionKey) && keyString.Length > 1 && keyString.Substring(0, 1) == "F")
                {
                    //If a function key is pushed with no modifiers, the "FunctionKey" modifier is enabled. In this case, allow a match with no modifiers;
                    int  FNum          = 0;
                    bool isNumericFkey = int.TryParse(keyString.Substring(1), out FNum);
                    if (isNumericFkey)
                    {
                        modifiers = fullscreenOption.modifiers | EventModifiers.FunctionKey;
                        fullscreenOption.modifiers = fullscreenOption.modifiers | EventModifiers.FunctionKey;
                    }
                }
                if (modifiers == fullscreenOption.modifiers)
                {
                    return(true);
                }
            }
            return(false);
        }
示例#6
0
        /// <summary>
        /// Toggle fullscreen at a position decided according to the current options.
        /// </summary>
        public static bool ToggleFullscreenAtOptionsSpecifiedPosition(EditorWindow editorWin, Type windowType, EditorFullscreenSettings.FullscreenOption fullscreenOptions, bool triggeredOnPlayStateChange)
        {
            var openAtPosition = fullscreenOptions.openAtPosition;

            if (openAtPosition == EditorFullscreenSettings.OpenFullscreenAtPosition.AtMousePosition)
            {
                return(ToggleFullscreenAtMousePosition(windowType, fullscreenOptions.showToolbarByDefault, triggeredOnPlayStateChange));
            }
            else
            {
                Vector2 atPosition = GetOptionsSpecifiedFullscreenOpenAtPosition(editorWin, windowType, fullscreenOptions);
                return(ToggleFullscreen(windowType, atPosition, fullscreenOptions.showToolbarByDefault, triggeredOnPlayStateChange));
            }
        }
 /// <summary>
 /// Triggers a Fullscreen Hotkey
 /// </summary>
 /// <param name="fullscreenOption">The fullscreen option to trigger the hotkey of.</param>
 internal static void TriggerFullscreenHotkey(EditorFullscreenSettings.FullscreenOption fullscreenOption)
 {
     TriggerFullscreenHotkey(fullscreenOption.hotkey, fullscreenOption.modifiers);
 }
示例#8
0
 /// <summary>
 /// Toggle fullscreen at a position decided according to the current options.
 /// </summary>
 public static bool ToggleFullscreenAtOptionsSpecifiedPosition(EditorWindow editorWin, Type windowType, EditorFullscreenSettings.FullscreenOption fullscreenOptions)
 {
     return(ToggleFullscreenAtOptionsSpecifiedPosition(editorWin, windowType, fullscreenOptions, false));
 }
示例#9
0
        /// <summary>
        /// Returns true if a window type is fullscreen on the screen specified by the given options.
        /// </summary>
        public static bool WindowTypeIsFullscreenAtOptionsSpecifiedPosition(Type windowType, EditorFullscreenSettings.FullscreenOption fullscreenOptions)
        {
            var  openAtPosition = fullscreenOptions.openAtPosition;
            bool isFullscreen   = false;

            switch (openAtPosition)
            {
            case EditorFullscreenSettings.OpenFullscreenAtPosition.AtMousePosition:
                EditorWindow mouseOverWin = EditorFullscreenState.GetMouseOverWindow();
                if (mouseOverWin != null && mouseOverWin.GetWindowType() == windowType)
                {
                    isFullscreen = mouseOverWin.IsFullscreen();
                }
                break;

            case EditorFullscreenSettings.OpenFullscreenAtPosition.None:
                isFullscreen = false;
                break;

            default:
                Vector2 openAtPos = GetOptionsSpecifiedFullscreenOpenAtPosition(null, windowType, fullscreenOptions);
                isFullscreen = WindowTypeIsFullscreenOnScreenAtPosition(windowType, openAtPos);
                break;
            }
            return(isFullscreen);
        }
示例#10
0
        /// <summary>
        /// Returns the fullscreen opening position of the specified window or window type according to the current options.
        /// </summary>
        private static Vector2 GetOptionsSpecifiedFullscreenOpenAtPosition(EditorWindow editorWin, Type windowType, EditorFullscreenSettings.FullscreenOption fullscreenOptions)
        {
            var     openAtPosition = fullscreenOptions.openAtPosition;
            Vector2 atPosition     = Vector2.zero;

            switch (openAtPosition)
            {
            case EditorFullscreenSettings.OpenFullscreenAtPosition.AtCurrentWindowPosition:
                if (editorWin != null)
                {
                    atPosition = editorWin.GetPointOnWindow();
                }
                else
                {
                    var  wins     = Resources.FindObjectsOfTypeAll <EditorWindow>();
                    bool foundWin = false;
                    foreach (var win in wins)
                    {
                        if (GetWindowType(windowType) == win.GetWindowType())
                        {
                            atPosition = win.GetContainerPosition().center;
                            foundWin   = true;
                            break;
                        }
                    }
                    if (!foundWin)
                    {
                        atPosition = EditorMainWindow.position.center;
                    }
                }
                break;

            case EditorFullscreenSettings.OpenFullscreenAtPosition.AtMousePosition:
                atPosition = EditorInput.MousePosition;
                break;

            case EditorFullscreenSettings.OpenFullscreenAtPosition.AtSpecifiedPosition:
                atPosition = fullscreenOptions.position;
                break;

            case EditorFullscreenSettings.OpenFullscreenAtPosition.AtSpecifiedPositionAndSize:
                atPosition = fullscreenOptions.position;
                break;

            case EditorFullscreenSettings.OpenFullscreenAtPosition.None:
                break;
            }
            return(atPosition);
        }
示例#11
0
        void AddFullscreenOption(ref EditorFullscreenSettings.FullscreenOption fullscreenOption, GUIContent label, bool showOpenAtOption, bool showToolbarOption, bool showHotkey, int[] displayedOpenAtOptions)
        {
            var indent = new GUIStyle();

            if (!showHotkey)
            {
                indent.margin.left = 10;
            }
            var initLabelWidth = EditorGUIUtility.labelWidth;

            if (!(showOpenAtOption || showToolbarOption))
            {
                EditorGUILayout.BeginHorizontal();
            }

            GUILayout.Label(label, smallHeadingStyle, new GUILayoutOption[0]);

            if (showOpenAtOption || showToolbarOption)
            {
                EditorGUIUtility.labelWidth = initLabelWidth - indent.margin.left;
                EditorGUILayout.BeginVertical(indent);
            }

            if (showOpenAtOption)
            {
                EditorGUILayout.BeginHorizontal();
                fullscreenOption.openAtPosition = (EditorFullscreenSettings.OpenFullscreenAtPosition)AddFilteredEnumPopup(new GUIContent("Enter Fullscreen"), fullscreenOption.openAtPosition, displayedOpenAtOptions);

                if (fullscreenOption.openAtPosition == EditorFullscreenSettings.OpenFullscreenAtPosition.AtSpecifiedPosition)
                {
                    var prevLabelWidth = EditorGUIUtility.labelWidth;
                    EditorGUIUtility.labelWidth = 15;
                    EditorGUILayout.BeginHorizontal(new[] { GUILayout.MaxWidth(100f) });
                    fullscreenOption.position.x = EditorGUILayout.IntField(new GUIContent("x", "x position"), (int)fullscreenOption.position.x, new GUILayoutOption[0]);
                    fullscreenOption.position.y = EditorGUILayout.IntField(new GUIContent("y", "y position"), (int)fullscreenOption.position.y, new GUILayoutOption[0]);
                    EditorGUILayout.EndHorizontal();
                    EditorGUIUtility.labelWidth = prevLabelWidth;
                }
                EditorGUILayout.EndHorizontal();
            }
            if (showOpenAtOption || showToolbarOption)
            {
                EditorGUILayout.BeginHorizontal();
            }
            if (showToolbarOption)
            {
                fullscreenOption.showToolbarByDefault = EditorGUILayout.Toggle("Show Toolbar By Default", fullscreenOption.showToolbarByDefault, new GUILayoutOption[0]);
            }

            //Hotkey
            if (showHotkey)
            {
                hotkeyWasSet = hotkeyWasSet || AddHotkeyField("Hotkey", ref fullscreenOption.hotkey, ref fullscreenOption.modifiers);
            }

            EditorGUILayout.EndHorizontal();
            if (showOpenAtOption || showToolbarOption)
            {
                EditorGUILayout.EndVertical();
                EditorGUIUtility.labelWidth = initLabelWidth;
            }
        }
示例#12
0
 void AddFullscreenOption(ref EditorFullscreenSettings.FullscreenOption fullscreenOption, string label, bool showOpenAtOption, bool showToolbarOption)
 {
     AddFullscreenOption(ref fullscreenOption, new GUIContent(label), showOpenAtOption, showToolbarOption, true, new[] { 1, 2, 3 });
 }