Exemple #1
0
        /// <summary>
        /// Start the fullscreen view.
        /// </summary>
        /// <param name="reference">A reference to clone properties from.</param>
        public virtual void Open(Object reference)
        {
            if (IsOpen)
            {
                return;
            }

            if (RequiresLayoutReload)
            {
                FullscreenUtility.SaveLayout(false);
            }

            ViewPassedAsReference = reference;

            if (reference)
            {
                if (reference.GetType() == Type || reference.GetType().IsSubclassOf(Type))
                {
                    CurrentOpenObject = Instantiate(reference);
                }
                else
                {
                    ViewPassedAsReference = null;
                    Debug.LogWarning("Reference object is not inherited from " + Type + ", it will be ignored");
                }
            }

            if (!CurrentOpenObject)
            {
                CurrentOpenObject = CreateInstance(Type);
            }

            CurrentOpenObject.InvokeMethod(SHOW_METHOD);
            Rect = FullscreenRects.GetFullscreenRect(CurrentOpenObject);

            if (!FullscreenPreferences.ToolbarVisible)
            {
                SetToolbarStatus(false);
            }

            Focus();

            FullscreenUtility.ShowFullscreenNotification(CurrentOpenWindow, MenuItemPath);

            for (var i = 0; i < 3; i++)                  //Prevents the editor from being completely black when switching fullscreen mode of main window.
            {
                InternalEditorUtility.RepaintAllViews(); //But it won't work every time, so we do it multiple times.
            }
            CurrentOpenContainerView.SetFieldValue("m_DontSaveToLayout", true);

#if UNITY_2018_1_OR_NEWER
            EditorApplication.wantsToQuit += WantsToQuit;
#endif
        }
        private static void ReloadPreferences()
        {
            preferenceKeys.Clear();

            var rectSourceTooltip     = string.Empty;
            var multipleWindowTooltip = string.Empty;

            rectSourceTooltip += "Controls where Fullscreen Views opens.\n\n";
            rectSourceTooltip += "Primary Screen: Fullscreen opens on the main screen;\n\n";
            rectSourceTooltip += "At Mouse Position: Fullscreen opens on the screen where the mouse pointer is (Windows only);\n\n";
            rectSourceTooltip += "Work Area: Fullscreen opens on the screen where the mouse pointer is, but won't cover the taskbar;\n\n";
            rectSourceTooltip += "Virtual Space: Fullscreen spans across all screens (Windows only);\n\n";
            rectSourceTooltip += "Custom Rect: Fullscreen opens on the given custom Rect.";

            multipleWindowTooltip += "Controls how the plugin will handle the opening and closing of Fullscreen Views.\n";
            multipleWindowTooltip += "Only One and Only One Immediate works best for single screen setups.\n\n";
            multipleWindowTooltip += "All: Close the fullscreen view under the cursor, if there's none a new one is created and opened;\n\n";
            multipleWindowTooltip += "One of Each Type: Allow only one Fullscreen View of each type, the types are Game View, Scene View, Main View and Focused View;\n\n";
            multipleWindowTooltip += "Only One: Close any open Fullscreen View before opening a new one;\n\n";
            multipleWindowTooltip += "Only One Immediate: Same as \"Only One\", but opens the newly created Fullscreen View immediately.";

            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", "Open a new instance of the Fullscreen View once the play mode is started, and close if it gets paused or stopped.");
            FullscreenOnPlayGiveWay = new PrefItem <bool>("FullscreenOnPlayGiveWay", true, "Give way", "Disable fullscreen on play feature if there is any other window as fullscreen");
            RectSource           = new PrefItem <RectSourceMode>("RectSource", OSXEditor ? RectSourceMode.WorkArea : RectSourceMode.AtMousePosition, "Rect Source", rectSourceTooltip);
            MutipleWindowMode    = new PrefItem <MutipleWindow>("MutipleFullscreen", MutipleWindow.OnlyOneImmediate, "Multiple Fullscreen", multipleWindowTooltip);
            CustomRect           = new PrefItem <Rect>("CustomRect", FullscreenRects.GetVirtualScreenRect(), "Custom Rect", string.Empty);
            DisableNotifications = new PrefItem <bool>("DisableNotifications", false, "Disable Notifications", "Disable the notifications that shows up when opening a new fullscreen view.");

            GameViewInputFix = new PrefItem <bool>("GameViewInputFix", InternalEditorUtility.GetUnityVersion() < new Version(2017, 1), "Game View Input Fix", "A fix for a bug with the inputs that may happen when " +
                                                   "two game view overlaps, this fix closes all the game views while a fullscreen view is open, and restores them once the fullscreen is closed.\n" +
                                                   "\"Multiple Fullscreen\" must be set to \"Only One\" for this to work properly.");

            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));
            }
        }