コード例 #1
0
        internal static void RestoreWindowStyle(EditorWindow editorWindow, Rect origPosition)
        {
            if (editorWindow == null)
            {
                return;
            }
            var windowHandle = GetProcessWindow(editorWindow);
            var state        = EditorFullscreenState.FindWindowState(editorWindow);

            if (state != null && windowHandle != IntPtr.Zero)
            {
                SetWindowLongPtr(windowHandle, GWL_STYLE, (IntPtr)state.OriginalStyle);
                LogWin32Error("Error setting window style");

                SetWindowPos(windowHandle, IntPtr.Zero, 0, 0, 0, 0, SWP.NOZORDER | SWP.FRAMECHANGED | SWP.NOACTIVATE | SWP.NOMOVE | SWP.NOSIZE);
            }
        }
コード例 #2
0
        /// Makes sure a window covers the taskbar when it is fullscreen
        private static bool MakeWindowCoverTaskBar(EditorWindow editorWindow, string windowClass, string windowTitle, SystemDisplay display)
        {
            IntPtr windowHandle = IntPtr.Zero;

            EWFDebugging.StartTimer("Making window cover taskbar");
            EWFDebugging.LogLine("Making window cover taskbar. " + (editorWindow == null ? "WindowTitle: " + (windowTitle == null ? "null" : windowTitle) : "EditorWindow: '" + editorWindow.GetWindowTitle() + "' Window Type: '" + editorWindow.GetType() + "' with class: '" + (windowClass == null ? "null" : windowClass) + "'"));
            if (editorWindow == null)
            {
                string fullscreenWindowClass = windowClass != null ? windowClass : "UnityPopupWndClass";
                windowHandle = GetProcessWindow(fullscreenWindowClass, windowTitle, true);
                if (windowHandle == IntPtr.Zero)
                {
                    windowHandle = GetProcessWindow(null, windowTitle, true);
                }
            }
            else
            {
                if (windowClass == null)
                {
                    windowHandle = GetProcessWindow(editorWindow);
                }
                else
                {
                    windowHandle = GetProcessWindow(windowClass, editorWindow);
                }
            }

            if (windowHandle == IntPtr.Zero)
            {
                EWFDebugging.LogError("Couldn't find window handle.");
                return(false);
            }

            IntPtr existingStyle   = GetWindowLongPtr(windowHandle, GWL_STYLE);
            IntPtr existingExStyle = GetWindowLongPtr(windowHandle, GWL_EXSTYLE);

            if (editorWindow != null)
            {
                var state = EditorFullscreenState.FindWindowState(editorWindow);
                if (state.OriginalStyle == 0)
                {
                    state.OriginalStyle = (int)existingStyle;
                }
                if (state.OriginalExStyle == 0)
                {
                    state.OriginalExStyle = (int)existingExStyle;
                }
            }

            if (EWFDebugging.Enabled)
            {
                EWFDebugging.LogLine("before Style: " + WindowStyleToString(existingStyle));
                EWFDebugging.LogLine("before ExStyle: " + WindowExStyleToString(existingExStyle));
            }

            SetWindowLongPtr(windowHandle, GWL_STYLE, (IntPtr)(WS_POPUP | WS_VISIBLE | ((uint)existingStyle & (WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_OVERLAPPED))));
            LogWin32Error("Error setting window style");

            SetWindowLongPtr(windowHandle, GWL_EXSTYLE, (IntPtr)((uint)existingExStyle & (WS_EX_LEFT | WS_EX_LTRREADING | WS_EX_RIGHTSCROLLBAR)));
            LogWin32Error("Error setting window ex style");

            SetWindowPos(windowHandle, IntPtr.Zero, (int)display.Bounds.x, (int)display.Bounds.y, (int)display.Bounds.width, (int)display.Bounds.height,
                         SWP.NOZORDER | SWP.FRAMECHANGED | SWP.NOACTIVATE);
            LogWin32Error("Error setting window position");

            if (EWFDebugging.Enabled)
            {
                existingStyle   = GetWindowLongPtr(windowHandle, GWL_STYLE);
                existingExStyle = GetWindowLongPtr(windowHandle, GWL_EXSTYLE);
                EWFDebugging.LogLine("after Style: " + WindowStyleToString(existingStyle));
                EWFDebugging.LogLine("after ExStyle: " + WindowExStyleToString(existingExStyle));
                EWFDebugging.LogTime("Making window cover taskbar");
            }

            return(true);
        }
コード例 #3
0
        static void OnFullscreenEvent(object window, Type windowType, Vector2 atPosition, bool enteredFullscreen)
        {
            if (enteredFullscreen)
            {
                lastFullscreenedWindowType = windowType;
            }
            bool toggledTopToolbar = false;

            if (window != null || windowType == EditorFullscreenState.MainWindowType)
            {
                EditorFullscreenState.WindowFullscreenState state = null;
                if (windowType == EditorFullscreenState.MainWindowType)
                {
                    state = EditorFullscreenState.FindWindowState(null, windowType);
                }
                else if (window != null)
                {
                    state = EditorFullscreenState.FindWindowState((EditorWindow)window);
                }

                if (state != null)
                {
                    var fullscreenOps = state.FullscreenOptions;
                    toggledTopToolbar = fullscreenOps != null && state.ShowTopToolbar != fullscreenOps.showToolbarByDefault;
                }
            }

            var character = DemoCharacter.instance;

            bool completedRoom = false;
            int  currentRoom   = character.enteredRooms.Count;

            switch (currentRoom)
            {
            case 1:
                if (windowType == EditorFullscreenState.MainWindowType && enteredFullscreen)
                {
                    completedRoom = true;
                }
                break;

            case 2:
                if (windowType == EditorFullscreenState.GameViewType && enteredFullscreen)
                {
                    completedRoom = true;
                }
                break;

            case 3:
                if (DemoCharacter.hints[2].Contains("ANOTHER"))
                {
                    //Must have game view fullscreen and open fullscreens scene view on another screen.
                    bool gameViewIsFullscreen  = EditorFullscreenController.WindowTypeIsFullscreen(EditorFullscreenState.GameViewType);
                    bool sceneViewIsFullscreen = EditorFullscreenController.WindowTypeIsFullscreen(EditorFullscreenState.SceneViewType);
                    if (enteredFullscreen && gameViewIsFullscreen && sceneViewIsFullscreen && (windowType == EditorFullscreenState.GameViewType || windowType == EditorFullscreenState.SceneViewType))
                    {
                        completedRoom = true;
                    }
                }
                else
                {
                    //Only have to open the scene view.
                    if (windowType == EditorFullscreenState.SceneViewType && enteredFullscreen)
                    {
                        completedRoom = true;
                    }
                }
                break;

            case 4:
                if (windowType == EditorFullscreenState.GameViewType && toggledTopToolbar)
                {
                    completedRoom = true;
                }
                if (completedRoom || DemoCharacter.completedRooms == 4)
                {
                    if (CompletedHint5() == true)
                    {
                        character.CompleteRoom(5, true);
                    }
                }
                break;

            case 5:
                if (CompletedHint5() == true)
                {
                    completedRoom = true;                               //Must have closed the window covering the main window.
                }
                break;

            case 8:
                if (enteredFullscreen && windowType == null)     //windowType is null when closing all fullscreen editor windows. In this case enteredFullscreen is true if at least one fullscreen window was closed.
                {
                    completedRoom = true;
                }
                break;

            case 9:
                if (!enteredFullscreen && windowType == typeof(EditorFullscreenSettingsWindow))
                {
                    completedRoom = true;
                }
                break;
            }

            if (completedRoom)
            {
                character.CompleteRoom(currentRoom);
            }
        }