Show() public method

public Show ( ShowMode showMode, bool loadPosition, bool displayImmediately ) : void
showMode ShowMode
loadPosition bool
displayImmediately bool
return void
Ejemplo n.º 1
0
        public void Show(Rect pixelPos, GUIContent content, Vector2 viewSize, Vector2 mouseScreenPosition)
        {
            m_Content = content;
            // scale not to be larger then maxArea pixels.
            var area = viewSize.x * viewSize.y;

            m_FullWindowSize = viewSize * Mathf.Sqrt(Mathf.Clamp01(kMaxArea / area));

            if (!m_Window)
            {
                m_Window = ScriptableObject.CreateInstance <ContainerWindow>();
                m_Window.m_DontSaveToLayout = true;
                SetMinMaxSizes(Vector2.zero, new Vector2(10000, 10000));
                SetWindowPos(pixelPos);
                m_Window.rootView = this;
            }
            else
            {
                SetWindowPos(pixelPos);
            }

            // Do not steal focus from the pane
            m_Window.Show(ShowMode.NoShadow, loadPosition: true, displayImmediately: false, setFocus: false);

            m_TargetRect = pixelPos;
        }
Ejemplo n.º 2
0
        public static void MakeMain()
        {
            ContainerWindow window  = ScriptableObject.CreateInstance <ContainerWindow>();
            MainWindow      window2 = ScriptableObject.CreateInstance <MainWindow>();

            window2.SetMinMaxSizes(new Vector2(770f, 300f), new Vector2(10000f, 10000f));
            window.mainView = window2;
            Resolution desktopResolution = InternalEditorUtility.GetDesktopResolution();
            int        num  = Mathf.Clamp((desktopResolution.width * 3) / 4, 800, 0x578);
            int        num2 = Mathf.Clamp((desktopResolution.height * 3) / 4, 600, 950);

            window.position = new Rect(60f, 20f, (float)num, (float)num2);
            window.Show(ShowMode.MainWindow, true, true);
            window.DisplayAllViews();
        }
Ejemplo n.º 3
0
        public static void MakeMain()
        {
            ContainerWindow containerWindow = ScriptableObject.CreateInstance <ContainerWindow>();
            MainView        mainView        = ScriptableObject.CreateInstance <MainView>();

            mainView.SetMinMaxSizes(MainView.kMinSize, MainView.kMaxSize);
            containerWindow.rootView = mainView;
            Resolution desktopResolution = InternalEditorUtility.GetDesktopResolution();
            int        num  = Mathf.Clamp(desktopResolution.width * 3 / 4, 800, 1400);
            int        num2 = Mathf.Clamp(desktopResolution.height * 3 / 4, 600, 950);

            containerWindow.position = new Rect(60f, 20f, (float)num, (float)num2);
            containerWindow.Show(ShowMode.MainWindow, true, true);
            containerWindow.DisplayAllViews();
        }
Ejemplo n.º 4
0
        private void Show(GUIView sourceView)
        {
            this.m_DelegateView = sourceView;
            ContainerWindow instance = ScriptableObject.CreateInstance <ContainerWindow>();

            instance.m_DontSaveToLayout = true;
            instance.title     = "EyeDropper";
            instance.hideFlags = HideFlags.DontSave;
            instance.mainView  = (View)this;
            instance.Show(ShowMode.PopupMenu, true, false);
            this.AddToAuxWindowList();
            instance.SetInvisible();
            this.SetMinMaxSizes(new Vector2(0.0f, 0.0f), new Vector2(10000f, 10000f));
            instance.position   = new Rect(-5000f, -5000f, 10000f, 10000f);
            this.wantsMouseMove = true;
            this.StealMouseCapture();
        }
Ejemplo n.º 5
0
        private void Show(GUIView sourceView)
        {
            this.m_DelegateView = sourceView;
            ContainerWindow containerWindow = ScriptableObject.CreateInstance <ContainerWindow>();

            containerWindow.m_DontSaveToLayout = true;
            containerWindow.title     = "EyeDropper";
            containerWindow.hideFlags = HideFlags.DontSave;
            containerWindow.rootView  = this;
            containerWindow.Show(ShowMode.PopupMenu, true, false);
            base.AddToAuxWindowList();
            containerWindow.SetInvisible();
            base.SetMinMaxSizes(new Vector2(0f, 0f), new Vector2(8192f, 8192f));
            containerWindow.position = new Rect(-4096f, -4096f, 8192f, 8192f);
            base.wantsMouseMove      = true;
            base.StealMouseCapture();
        }
Ejemplo n.º 6
0
 internal void ShowWithMode(ShowMode mode)
 {
     if (this.m_Parent == null)
     {
         SavedGUIState   savedGUIState   = SavedGUIState.Create();
         ContainerWindow containerWindow = ScriptableObject.CreateInstance <ContainerWindow>();
         containerWindow.title = this.titleContent.text;
         HostView hostView = ScriptableObject.CreateInstance <HostView>();
         hostView.actualView = this;
         Rect position = this.m_Parent.borderSize.Add(new Rect(this.position.x, this.position.y, this.position.width, this.position.height));
         containerWindow.position = position;
         containerWindow.rootView = hostView;
         this.MakeParentsSettingsMatchMe();
         containerWindow.Show(mode, true, false);
         savedGUIState.ApplyAndForget();
     }
 }
Ejemplo n.º 7
0
        internal static void CreateNewWindowForEditorWindow(EditorWindow window, Vector2 screenPosition, bool loadPosition, bool showImmediately)
        {
            ContainerWindow window2 = ScriptableObject.CreateInstance <ContainerWindow>();
            SplitView       view    = ScriptableObject.CreateInstance <SplitView>();

            window2.rootView = view;
            DockArea child = ScriptableObject.CreateInstance <DockArea>();

            view.AddChild(child);
            child.AddTab(window);
            Rect rect = window.m_Parent.borderSize.Add(new Rect(screenPosition.x, screenPosition.y, window.position.width, window.position.height));

            window2.position = rect;
            view.position    = new Rect(0f, 0f, rect.width, rect.height);
            window.MakeParentsSettingsMatchMe();
            window2.Show(ShowMode.NormalWindow, loadPosition, showImmediately);
            window2.OnResize();
        }
Ejemplo n.º 8
0
        internal static void CreateNewWindowForEditorWindow(EditorWindow window, Vector2 screenPosition, bool loadPosition, bool showImmediately)
        {
            ContainerWindow instance1 = ScriptableObject.CreateInstance <ContainerWindow>();
            SplitView       instance2 = ScriptableObject.CreateInstance <SplitView>();

            instance1.mainView = (View)instance2;
            DockArea instance3 = ScriptableObject.CreateInstance <DockArea>();

            instance2.AddChild((View)instance3);
            instance3.AddTab(window);
            Rect rect = window.m_Parent.borderSize.Add(new Rect(screenPosition.x, screenPosition.y, window.position.width, window.position.height));

            instance1.position = rect;
            instance2.position = new Rect(0.0f, 0.0f, rect.width, rect.height);
            window.MakeParentsSettingsMatchMe();
            instance1.Show(ShowMode.NormalWindow, loadPosition, showImmediately);
            instance1.OnResize();
        }
Ejemplo n.º 9
0
        internal static void CreateNewWindowForEditorWindow(EditorWindow window, Vector2 screenPosition, bool loadPosition, bool showImmediately)
        {
            ContainerWindow containerWindow = ScriptableObject.CreateInstance <ContainerWindow>();
            SplitView       splitView       = ScriptableObject.CreateInstance <SplitView>();

            containerWindow.rootView = splitView;
            DockArea dockArea = ScriptableObject.CreateInstance <DockArea>();

            splitView.AddChild(dockArea);
            dockArea.AddTab(window);
            Rect position = window.m_Parent.borderSize.Add(new Rect(screenPosition.x, screenPosition.y, window.position.width, window.position.height));

            containerWindow.position = position;
            splitView.position       = new Rect(0f, 0f, position.width, position.height);
            window.MakeParentsSettingsMatchMe();
            containerWindow.Show(ShowMode.NormalWindow, loadPosition, showImmediately);
            containerWindow.OnResize();
        }
Ejemplo n.º 10
0
        public static void MakeMain()
        {
            //Set up default window size
            ContainerWindow cw   = ScriptableObject.CreateInstance <ContainerWindow>();
            var             main = ScriptableObject.CreateInstance <MainView>();

            main.SetMinMaxSizes(kMinSize, kMaxSize);
            cw.rootView = main;

            Resolution res    = Screen.currentResolution;
            int        width  = Mathf.Clamp(res.width * 3 / 4, 800, 1400);
            int        height = Mathf.Clamp(res.height * 3 / 4, 600, 950);

            cw.position = new Rect(60, 20, width, height);

            cw.Show(ShowMode.MainWindow, loadPosition: true, displayImmediately: true, setFocus: true);
            cw.DisplayAllViews();
        }
Ejemplo n.º 11
0
        // Internal stuff:
        // Helper to show this EditorWindow
        internal static void CreateNewWindowForEditorWindow(EditorWindow window, bool loadPosition, bool showImmediately, bool setFocus = true)
        {
            ContainerWindow cw = ScriptableObject.CreateInstance <ContainerWindow>();
            SplitView       sw = ScriptableObject.CreateInstance <SplitView>();

            cw.rootView = sw;
            DockArea da = ScriptableObject.CreateInstance <DockArea>();

            da.AddTab(window, setFocus);
            sw.AddChild(da);
            Rect r = window.m_Parent.borderSize.Add(window.position);

            cw.position = r;
            sw.position = new Rect(0, 0, r.width, r.height);
            window.MakeParentsSettingsMatchMe();
            cw.Show(ShowMode.NormalWindow, loadPosition, showImmediately, setFocus: true);
            //Need this, as show my change the size of the window, due to screen constraints
            cw.OnResize();
        }
Ejemplo n.º 12
0
        internal void ShowWithMode(ShowMode mode)
        {
            if (!((UnityEngine.Object) this.m_Parent == (UnityEngine.Object)null))
            {
                return;
            }
            SavedGUIState   savedGuiState = SavedGUIState.Create();
            ContainerWindow instance1     = ScriptableObject.CreateInstance <ContainerWindow>();

            instance1.title = this.titleContent.text;
            HostView instance2 = ScriptableObject.CreateInstance <HostView>();

            instance2.actualView = this;
            Rect rect = this.m_Parent.borderSize.Add(new Rect(this.position.x, this.position.y, this.position.width, this.position.height));

            instance1.position = rect;
            instance1.mainView = (View)instance2;
            this.MakeParentsSettingsMatchMe();
            instance1.Show(mode, true, false);
            savedGuiState.ApplyAndForget();
        }
Ejemplo n.º 13
0
        private static void Start(GUIView viewToUpdate, Action <Color> colorPickedCallback, bool stealFocus)
        {
            EyeDropper.instance.m_DelegateView        = viewToUpdate;
            EyeDropper.instance.m_ColorPickedCallback = colorPickedCallback;
            ContainerWindow containerWindow = ScriptableObject.CreateInstance <ContainerWindow>();

            containerWindow.m_DontSaveToLayout = true;
            containerWindow.title     = "EyeDropper";
            containerWindow.hideFlags = HideFlags.DontSave;
            containerWindow.rootView  = EyeDropper.instance;
            containerWindow.Show(ShowMode.PopupMenu, true, false);
            EyeDropper.instance.AddToAuxWindowList();
            containerWindow.SetInvisible();
            EyeDropper.instance.SetMinMaxSizes(new Vector2(0f, 0f), new Vector2(8192f, 8192f));
            containerWindow.position           = new Rect(-4096f, -4096f, 8192f, 8192f);
            EyeDropper.instance.wantsMouseMove = true;
            EyeDropper.instance.StealMouseCapture();
            if (stealFocus)
            {
                EyeDropper.instance.Focus();
            }
        }
Ejemplo n.º 14
0
        internal void ShowWithMode(ShowMode mode)
        {
            if (m_Parent == null)
            {
                SavedGUIState oldState = SavedGUIState.Create();

                ContainerWindow cw = ScriptableObject.CreateInstance <ContainerWindow>();
                cw.title = titleContent.text;
                HostView host = ScriptableObject.CreateInstance <HostView>();
                host.actualView = this; // Among other things, this sets m_Parent to host

                Rect r = m_Parent.borderSize.Add(new Rect(position.x, position.y, position.width, position.height));
                // Order is important here: first set rect of container, then assign main view, then apply various settings, then show.
                // Otherwise the rect won't be set until first resize happens.
                cw.position = r;
                cw.rootView = host;
                MakeParentsSettingsMatchMe();
                cw.Show(mode, loadPosition: true, displayImmediately: false, setFocus: true);
                // set min/max size now that native window is not null so that it will e.g., use proper styleMask on macOS
                cw.SetMinMaxSizes(minSize, maxSize);

                oldState.ApplyAndForget();
            }
        }
Ejemplo n.º 15
0
        public static bool LoadWindowLayout(string path, bool newProjectLayoutWasCreated)
        {
            Rect position = default(Rect);

            UnityEngine.Object[] array  = Resources.FindObjectsOfTypeAll(typeof(ContainerWindow));
            UnityEngine.Object[] array2 = array;
            for (int i = 0; i < array2.Length; i++)
            {
                ContainerWindow containerWindow = (ContainerWindow)array2[i];
                if (containerWindow.showMode == ShowMode.MainWindow)
                {
                    position = containerWindow.position;
                }
            }
            bool result;

            try
            {
                ContainerWindow.SetFreezeDisplay(true);
                WindowLayout.CloseWindows();
                UnityEngine.Object[]      array3 = InternalEditorUtility.LoadSerializedFileAndForget(path);
                List <UnityEngine.Object> list   = new List <UnityEngine.Object>();
                int j = 0;
                while (j < array3.Length)
                {
                    UnityEngine.Object @object      = array3[j];
                    EditorWindow       editorWindow = @object as EditorWindow;
                    if (editorWindow != null)
                    {
                        if (!(editorWindow.m_Parent == null))
                        {
                            goto IL_17D;
                        }
                        UnityEngine.Object.DestroyImmediate(editorWindow, true);
                        UnityEngine.Debug.LogError(string.Concat(new object[]
                        {
                            "Removed unparented EditorWindow while reading window layout: window #",
                            j,
                            ", type=",
                            @object.GetType().ToString(),
                            ", instanceID=",
                            @object.GetInstanceID()
                        }));
                    }
                    else
                    {
                        DockArea dockArea = @object as DockArea;
                        if (!(dockArea != null) || dockArea.m_Panes.Count != 0)
                        {
                            goto IL_17D;
                        }
                        dockArea.Close(null);
                        UnityEngine.Debug.LogError(string.Concat(new object[]
                        {
                            "Removed empty DockArea while reading window layout: window #",
                            j,
                            ", instanceID=",
                            @object.GetInstanceID()
                        }));
                    }
IL_187:
                    j++;
                    continue;
IL_17D:
                    list.Add(@object);
                    goto IL_187;
                }
                ContainerWindow containerWindow2 = null;
                ContainerWindow containerWindow3 = null;
                for (int k = 0; k < list.Count; k++)
                {
                    ContainerWindow containerWindow4 = list[k] as ContainerWindow;
                    if (containerWindow4 != null && containerWindow4.showMode == ShowMode.MainWindow)
                    {
                        containerWindow3 = containerWindow4;
                        if ((double)position.width != 0.0)
                        {
                            containerWindow2          = containerWindow4;
                            containerWindow2.position = position;
                        }
                    }
                }
                for (int l = 0; l < list.Count; l++)
                {
                    UnityEngine.Object object2 = list[l];
                    if (object2 == null)
                    {
                        UnityEngine.Debug.LogError("Error while reading window layout: window #" + l + " is null");
                    }
                    else if (object2.GetType() == null)
                    {
                        UnityEngine.Debug.LogError(string.Concat(new object[]
                        {
                            "Error while reading window layout: window #",
                            l,
                            " type is null, instanceID=",
                            object2.GetInstanceID()
                        }));
                    }
                    else if (newProjectLayoutWasCreated)
                    {
                        MethodInfo method = object2.GetType().GetMethod("OnNewProjectLayoutWasCreated", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
                        if (method != null)
                        {
                            method.Invoke(object2, null);
                        }
                    }
                }
                if (containerWindow2)
                {
                    containerWindow2.position = position;
                    containerWindow2.OnResize();
                }
                if (containerWindow3 == null)
                {
                    UnityEngine.Debug.LogError("Error while reading window layout: no main window found");
                    throw new Exception();
                }
                containerWindow3.Show(containerWindow3.showMode, true, true);
                for (int m = 0; m < list.Count; m++)
                {
                    EditorWindow editorWindow2 = list[m] as EditorWindow;
                    if (editorWindow2)
                    {
                        editorWindow2.minSize = editorWindow2.minSize;
                    }
                    ContainerWindow containerWindow5 = list[m] as ContainerWindow;
                    if (containerWindow5 && containerWindow5 != containerWindow3)
                    {
                        containerWindow5.Show(containerWindow5.showMode, true, true);
                    }
                }
                GameView gameView = WindowLayout.GetMaximizedWindow() as GameView;
                if (gameView != null && gameView.maximizeOnPlay)
                {
                    WindowLayout.Unmaximize(gameView);
                }
                if (newProjectLayoutWasCreated)
                {
                    if (UnityConnect.instance.online && UnityConnect.instance.loggedIn && UnityConnect.instance.shouldShowServicesWindow)
                    {
                        UnityConnectServiceCollection.instance.ShowService("Hub", true);
                    }
                    else
                    {
                        UnityConnectServiceCollection.instance.CloseServices();
                    }
                }
            }
            catch (Exception arg)
            {
                UnityEngine.Debug.LogError("Failed to load window layout: " + arg);
                int num = 0;
                if (!Application.isTestRun)
                {
                    num = EditorUtility.DisplayDialogComplex("Failed to load window layout", "This can happen if layout contains custom windows and there are compile errors in the project.", "Load Default Layout", "Quit", "Revert Factory Settings");
                }
                if (num != 0)
                {
                    if (num != 1)
                    {
                        if (num == 2)
                        {
                            WindowLayout.RevertFactorySettings();
                        }
                    }
                    else
                    {
                        EditorApplication.Exit(0);
                    }
                }
                else
                {
                    WindowLayout.LoadDefaultLayout();
                }
                result = false;
                return(result);
            }
            finally
            {
                ContainerWindow.SetFreezeDisplay(false);
                if (Path.GetExtension(path) == ".wlt")
                {
                    Toolbar.lastLoadedLayoutName = Path.GetFileNameWithoutExtension(path);
                }
                else
                {
                    Toolbar.lastLoadedLayoutName = null;
                }
            }
            result = true;
            return(result);
        }
        public static bool LoadWindowLayout(string path, bool newProjectLayoutWasCreated)
        {
            Rect mainWindowPosition = new Rect();

            UnityObject[] containers = Resources.FindObjectsOfTypeAll(typeof(ContainerWindow));
            foreach (ContainerWindow window in containers)
            {
                if (window.showMode == ShowMode.MainWindow)
                {
                    mainWindowPosition = window.position;
                }
            }

            bool layoutLoadingIssue = false;

            // Load new windows and show them
            try
            {
                ContainerWindow.SetFreezeDisplay(true);

                CloseWindows();

                // Load data
                UnityObject[] loadedWindows = InternalEditorUtility.LoadSerializedFileAndForget(path);

                if (loadedWindows == null || loadedWindows.Length == 0)
                {
                    throw new ArgumentException("Window layout at '" + path + "' could not be loaded.");
                }

                List <UnityObject> newWindows = new List <UnityObject>();

                // At this point, unparented editor windows are neither desired nor desirable.
                // This can be caused by (legacy) serialization of FallbackEditorWindows or
                // other serialization hiccups (note that unparented editor windows should not exist in theory).
                // Same goes for empty DockAreas (no panes).  Leave them behind.
                for (int i = 0; i < loadedWindows.Length; i++)
                {
                    UnityObject o = loadedWindows[i];

                    EditorWindow editorWin = o as EditorWindow;
                    if (editorWin != null)
                    {
                        if (editorWin.m_Parent == null)
                        {
                            UnityObject.DestroyImmediate(editorWin, true);
                            Console.WriteLine("LoadWindowLayout: Removed unparented EditorWindow while reading window layout: window #" + i + ", type=" +
                                              o.GetType().ToString() + ", instanceID=" + o.GetInstanceID());
                            layoutLoadingIssue = true;
                            continue;
                        }
                    }
                    else
                    {
                        DockArea dockArea = o as DockArea;
                        if (dockArea != null && dockArea.m_Panes.Count == 0)
                        {
                            dockArea.Close(null);
                            Console.WriteLine("LoadWindowLayout: Removed empty DockArea while reading window layout: window #" + i + ", instanceID=" +
                                              o.GetInstanceID());
                            layoutLoadingIssue = true;
                            continue;
                        }
                    }

                    newWindows.Add(o);
                }

                ContainerWindow mainWindowToSetSize = null;
                ContainerWindow mainWindow          = null;

                for (int i = 0; i < newWindows.Count; i++)
                {
                    ContainerWindow cur = newWindows[i] as ContainerWindow;
                    if (cur != null && cur.showMode == ShowMode.MainWindow)
                    {
                        mainWindow = cur;
                        if (mainWindowPosition.width != 0.0)
                        {
                            mainWindowToSetSize          = cur;
                            mainWindowToSetSize.position = mainWindowPosition;
                        }
                    }
                }

                for (int i = 0; i < newWindows.Count; i++)
                {
                    UnityObject o = newWindows[i];
                    if (o == null)
                    {
                        Console.WriteLine("LoadWindowLayout: Error while reading window layout: window #" + i + " is null");
                        layoutLoadingIssue = true;
                        // Keep going
                    }
                    else if (o.GetType() == null)
                    {
                        Console.WriteLine("LoadWindowLayout: Error while reading window layout: window #" + i + " type is null, instanceID=" + o.GetInstanceID());
                        layoutLoadingIssue = true;
                        // Keep going
                    }
                    else
                    {
                        if (newProjectLayoutWasCreated)
                        {
                            MethodInfo method = o.GetType().GetMethod("OnNewProjectLayoutWasCreated", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
                            if (method != null)
                            {
                                method.Invoke(o, null);
                            }
                        }
                    }
                }

                if (mainWindowToSetSize)
                {
                    mainWindowToSetSize.position = mainWindowPosition;
                    mainWindowToSetSize.OnResize();
                }

                // Always show main window before other windows. So that other windows can
                // get their parent/owner.
                if (mainWindow == null)
                {
                    Debug.LogError("Error while reading window layout: no main window found");
                    throw new System.Exception();
                }
                mainWindow.Show(mainWindow.showMode, true, true);

                // Show other windows
                for (int i = 0; i < newWindows.Count; i++)
                {
                    EditorWindow win = newWindows[i] as EditorWindow;
                    if (win)
                    {
                        win.minSize = win.minSize; // Causes minSize to be propagated upwards to parents!
                    }
                    ContainerWindow containerWindow = newWindows[i] as ContainerWindow;
                    if (containerWindow && containerWindow != mainWindow)
                    {
                        containerWindow.Show(containerWindow.showMode, true, true);
                    }
                }

                // Unmaximize maximized GameView if maximize on play is enabled
                GameView gameView = GetMaximizedWindow() as GameView;
                if (gameView != null && gameView.maximizeOnPlay)
                {
                    Unmaximize(gameView);
                }

                // For new projects, show services window if and only if online and logged in
                if (newProjectLayoutWasCreated)
                {
                    if (UnityConnect.instance.online && UnityConnect.instance.loggedIn && UnityConnect.instance.shouldShowServicesWindow)
                    {
                        UnityConnectServiceCollection.instance.ShowService(HubAccess.kServiceName, true, "new_project_created");
                    }
                    else
                    {
                        UnityConnectServiceCollection.instance.CloseServices();
                    }
                }
            }
            catch (System.Exception ex)
            {
                Debug.LogError("Failed to load window layout: " + ex);

                int option = 0;


                UnityObject[] containerWindows = Resources.FindObjectsOfTypeAll(typeof(ContainerWindow));

                // Only show dialog if an actual window is present. If not, revert to default immediately
                if (!Application.isTestRun && containerWindows.Length > 0)
                {
                    option = EditorUtility.DisplayDialogComplex("Failed to load window layout", "This can happen if layout contains custom windows and there are compile errors in the project.", "Load Default Layout", "Quit", "Revert Factory Settings");
                }

                switch (option)
                {
                case 0:
                    LoadDefaultLayout();
                    break;

                case 1:
                    EditorApplication.Exit(0);
                    break;

                case 2:
                    RevertFactorySettings();
                    break;
                }

                return(false);
            }
            finally
            {
                ContainerWindow.SetFreezeDisplay(false);

                if (Path.GetExtension(path) == ".wlt")
                {
                    Toolbar.lastLoadedLayoutName = Path.GetFileNameWithoutExtension(path);
                }
                else
                {
                    Toolbar.lastLoadedLayoutName = null;
                }
            }

            if (layoutLoadingIssue)
            {
                Debug.Log("The editor layout could not be fully loaded, this can happen when the layout contains EditorWindows not available in this project");
            }

            return(true);
        }
Ejemplo n.º 17
0
        public static bool LoadWindowLayout(string path, bool newProjectLayoutWasCreated)
        {
            Rect rect = new Rect();

            foreach (ContainerWindow containerWindow in Resources.FindObjectsOfTypeAll(typeof(ContainerWindow)))
            {
                if (containerWindow.showMode == ShowMode.MainWindow)
                {
                    rect = containerWindow.position;
                }
            }
            try
            {
                ContainerWindow.SetFreezeDisplay(true);
                WindowLayout.CloseWindows();
                UnityEngine.Object[] objectArray      = InternalEditorUtility.LoadSerializedFileAndForget(path);
                ContainerWindow      containerWindow1 = (ContainerWindow)null;
                ContainerWindow      containerWindow2 = (ContainerWindow)null;
                foreach (UnityEngine.Object @object in objectArray)
                {
                    ContainerWindow containerWindow3 = @object as ContainerWindow;
                    if ((UnityEngine.Object)containerWindow3 != (UnityEngine.Object)null && containerWindow3.showMode == ShowMode.MainWindow)
                    {
                        containerWindow2 = containerWindow3;
                        if ((double)rect.width != 0.0)
                        {
                            containerWindow1          = containerWindow3;
                            containerWindow1.position = rect;
                        }
                    }
                }
                int num = 0;
                foreach (UnityEngine.Object @object in objectArray)
                {
                    if (@object == (UnityEngine.Object)null)
                    {
                        UnityEngine.Debug.LogError((object)("Error while reading window layout: window #" + (object)num + " is null"));
                        throw new Exception();
                    }
                    if (@object.GetType() == null)
                    {
                        UnityEngine.Debug.LogError((object)("Error while reading window layout: window #" + (object)num + " type is null, instanceID=" + (object)@object.GetInstanceID()));
                        throw new Exception();
                    }
                    if (newProjectLayoutWasCreated)
                    {
                        MethodInfo method = @object.GetType().GetMethod("OnNewProjectLayoutWasCreated", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
                        if (method != null)
                        {
                            method.Invoke((object)@object, (object[])null);
                        }
                    }
                    ++num;
                }
                if ((bool)((UnityEngine.Object)containerWindow1))
                {
                    containerWindow1.position = rect;
                    containerWindow1.OnResize();
                }
                if ((UnityEngine.Object)containerWindow2 == (UnityEngine.Object)null)
                {
                    UnityEngine.Debug.LogError((object)"Error while reading window layout: no main window found");
                    throw new Exception();
                }
                containerWindow2.Show(containerWindow2.showMode, true, true);
                foreach (UnityEngine.Object @object in objectArray)
                {
                    EditorWindow editorWindow = @object as EditorWindow;
                    if ((bool)((UnityEngine.Object)editorWindow))
                    {
                        editorWindow.minSize = editorWindow.minSize;
                    }
                    ContainerWindow containerWindow3 = @object as ContainerWindow;
                    if ((bool)((UnityEngine.Object)containerWindow3) && (UnityEngine.Object)containerWindow3 != (UnityEngine.Object)containerWindow2)
                    {
                        containerWindow3.Show(containerWindow3.showMode, true, true);
                    }
                }
                GameView maximizedWindow = WindowLayout.GetMaximizedWindow() as GameView;
                if ((UnityEngine.Object)maximizedWindow != (UnityEngine.Object)null)
                {
                    if (maximizedWindow.maximizeOnPlay)
                    {
                        WindowLayout.Unmaximize((EditorWindow)maximizedWindow);
                    }
                }
            }
            catch (Exception ex)
            {
                UnityEngine.Debug.LogError((object)("Failed to load window layout: " + (object)ex));
                switch (EditorUtility.DisplayDialogComplex("Failed to load window layout", "This can happen if layout contains custom windows and there are compile errors in the project.", "Load Default Layout", "Quit", "Revert Factory Settings"))
                {
                case 0:
                    WindowLayout.LoadDefaultLayout();
                    break;

                case 1:
                    EditorApplication.Exit(0);
                    break;

                case 2:
                    WindowLayout.RevertFactorySettings();
                    break;
                }
                return(false);
            }
            finally
            {
                ContainerWindow.SetFreezeDisplay(false);
                Toolbar.lastLoadedLayoutName = !(Path.GetExtension(path) == ".wlt") ? (string)null : Path.GetFileNameWithoutExtension(path);
            }
            return(true);
        }
Ejemplo n.º 18
0
 public static bool LoadWindowLayout(string path, bool newProjectLayoutWasCreated)
 {
     Rect position = new Rect();
     UnityEngine.Object[] objArray = UnityEngine.Resources.FindObjectsOfTypeAll(typeof(ContainerWindow));
     foreach (ContainerWindow window in objArray)
     {
         if (window.showMode == ShowMode.MainWindow)
         {
             position = window.position;
         }
     }
     try
     {
         ContainerWindow.SetFreezeDisplay(true);
         CloseWindows();
         UnityEngine.Object[] objArray3 = InternalEditorUtility.LoadSerializedFileAndForget(path);
         List<UnityEngine.Object> list = new List<UnityEngine.Object>();
         for (int i = 0; i < objArray3.Length; i++)
         {
             UnityEngine.Object item = objArray3[i];
             EditorWindow window2 = item as EditorWindow;
             if (window2 != null)
             {
                 if (window2.m_Parent == null)
                 {
                     UnityEngine.Object.DestroyImmediate(window2, true);
                     UnityEngine.Debug.LogError(string.Concat(new object[] { "Removed unparented EditorWindow while reading window layout: window #", i, ", type=", item.GetType().ToString(), ", instanceID=", item.GetInstanceID() }));
                     continue;
                 }
             }
             else
             {
                 DockArea area = item as DockArea;
                 if ((area != null) && (area.m_Panes.Count == 0))
                 {
                     area.Close(null);
                     UnityEngine.Debug.LogError(string.Concat(new object[] { "Removed empty DockArea while reading window layout: window #", i, ", instanceID=", item.GetInstanceID() }));
                     continue;
                 }
             }
             list.Add(item);
         }
         ContainerWindow window3 = null;
         ContainerWindow window4 = null;
         for (int j = 0; j < list.Count; j++)
         {
             ContainerWindow window5 = list[j] as ContainerWindow;
             if ((window5 != null) && (window5.showMode == ShowMode.MainWindow))
             {
                 window4 = window5;
                 if (position.width != 0.0)
                 {
                     window3 = window5;
                     window3.position = position;
                 }
             }
         }
         for (int k = 0; k < list.Count; k++)
         {
             UnityEngine.Object obj3 = list[k];
             if (obj3 == null)
             {
                 UnityEngine.Debug.LogError("Error while reading window layout: window #" + k + " is null");
             }
             else if (obj3.GetType() == null)
             {
                 UnityEngine.Debug.LogError(string.Concat(new object[] { "Error while reading window layout: window #", k, " type is null, instanceID=", obj3.GetInstanceID() }));
             }
             else if (newProjectLayoutWasCreated)
             {
                 MethodInfo method = obj3.GetType().GetMethod("OnNewProjectLayoutWasCreated", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);
                 if (method != null)
                 {
                     method.Invoke(obj3, null);
                 }
             }
         }
         if (window3 != null)
         {
             window3.position = position;
             window3.OnResize();
         }
         if (window4 == null)
         {
             UnityEngine.Debug.LogError("Error while reading window layout: no main window found");
             throw new Exception();
         }
         window4.Show(window4.showMode, true, true);
         for (int m = 0; m < list.Count; m++)
         {
             EditorWindow window6 = list[m] as EditorWindow;
             if (window6 != null)
             {
                 window6.minSize = window6.minSize;
             }
             ContainerWindow window7 = list[m] as ContainerWindow;
             if ((window7 != null) && (window7 != window4))
             {
                 window7.Show(window7.showMode, true, true);
             }
         }
         GameView maximizedWindow = GetMaximizedWindow() as GameView;
         if ((maximizedWindow != null) && maximizedWindow.maximizeOnPlay)
         {
             Unmaximize(maximizedWindow);
         }
         if (newProjectLayoutWasCreated)
         {
             if ((UnityConnect.instance.online && UnityConnect.instance.loggedIn) && UnityConnect.instance.shouldShowServicesWindow)
             {
                 UnityConnectServiceCollection.instance.ShowService("Hub", true);
             }
             else
             {
                 UnityConnectServiceCollection.instance.CloseServices();
             }
         }
     }
     catch (Exception exception)
     {
         UnityEngine.Debug.LogError("Failed to load window layout: " + exception);
         int num6 = 0;
         if (!Application.isTestRun)
         {
             num6 = EditorUtility.DisplayDialogComplex("Failed to load window layout", "This can happen if layout contains custom windows and there are compile errors in the project.", "Load Default Layout", "Quit", "Revert Factory Settings");
         }
         if (num6 == 0)
         {
             LoadDefaultLayout();
         }
         else if (num6 == 1)
         {
             EditorApplication.Exit(0);
         }
         else if (num6 == 2)
         {
             RevertFactorySettings();
         }
         return false;
     }
     finally
     {
         ContainerWindow.SetFreezeDisplay(false);
         if (Path.GetExtension(path) == ".wlt")
         {
             Toolbar.lastLoadedLayoutName = Path.GetFileNameWithoutExtension(path);
         }
         else
         {
             Toolbar.lastLoadedLayoutName = null;
         }
     }
     return true;
 }
Ejemplo n.º 19
0
        public static bool LoadWindowLayout(string path, bool newProjectLayoutWasCreated)
        {
            Rect position = default(Rect);

            UnityEngine.Object[] array  = Resources.FindObjectsOfTypeAll(typeof(ContainerWindow));
            UnityEngine.Object[] array2 = array;
            for (int i = 0; i < array2.Length; i++)
            {
                ContainerWindow containerWindow = (ContainerWindow)array2[i];
                if (containerWindow.showMode == ShowMode.MainWindow)
                {
                    position = containerWindow.position;
                }
            }
            try
            {
                ContainerWindow.SetFreezeDisplay(true);
                WindowLayout.CloseWindows();
                UnityEngine.Object[] array3           = InternalEditorUtility.LoadSerializedFileAndForget(path);
                ContainerWindow      containerWindow2 = null;
                ContainerWindow      containerWindow3 = null;
                UnityEngine.Object[] array4           = array3;
                for (int j = 0; j < array4.Length; j++)
                {
                    UnityEngine.Object @object          = array4[j];
                    ContainerWindow    containerWindow4 = @object as ContainerWindow;
                    if (containerWindow4 != null && containerWindow4.showMode == ShowMode.MainWindow)
                    {
                        containerWindow3 = containerWindow4;
                        if ((double)position.width != 0.0)
                        {
                            containerWindow2          = containerWindow4;
                            containerWindow2.position = position;
                        }
                    }
                }
                int num = 0;
                UnityEngine.Object[] array5 = array3;
                for (int k = 0; k < array5.Length; k++)
                {
                    UnityEngine.Object object2 = array5[k];
                    if (object2 == null)
                    {
                        UnityEngine.Debug.LogError("Error while reading window layout: window #" + num + " is null");
                        throw new Exception();
                    }
                    if (object2.GetType() == null)
                    {
                        UnityEngine.Debug.LogError(string.Concat(new object[]
                        {
                            "Error while reading window layout: window #",
                            num,
                            " type is null, instanceID=",
                            object2.GetInstanceID()
                        }));
                        throw new Exception();
                    }
                    if (newProjectLayoutWasCreated)
                    {
                        MethodInfo method = object2.GetType().GetMethod("OnNewProjectLayoutWasCreated", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
                        if (method != null)
                        {
                            method.Invoke(object2, null);
                        }
                    }
                    num++;
                }
                if (containerWindow2)
                {
                    containerWindow2.position = position;
                    containerWindow2.OnResize();
                }
                if (containerWindow3 == null)
                {
                    UnityEngine.Debug.LogError("Error while reading window layout: no main window found");
                    throw new Exception();
                }
                containerWindow3.Show(containerWindow3.showMode, true, true);
                UnityEngine.Object[] array6 = array3;
                for (int l = 0; l < array6.Length; l++)
                {
                    UnityEngine.Object object3      = array6[l];
                    EditorWindow       editorWindow = object3 as EditorWindow;
                    if (editorWindow)
                    {
                        editorWindow.minSize = editorWindow.minSize;
                    }
                    ContainerWindow containerWindow5 = object3 as ContainerWindow;
                    if (containerWindow5 && containerWindow5 != containerWindow3)
                    {
                        containerWindow5.Show(containerWindow5.showMode, true, true);
                    }
                }
                GameView gameView = WindowLayout.GetMaximizedWindow() as GameView;
                if (gameView != null && gameView.maximizeOnPlay)
                {
                    WindowLayout.Unmaximize(gameView);
                }
            }
            catch (Exception arg)
            {
                UnityEngine.Debug.LogError("Failed to load window layout: " + arg);
                switch (EditorUtility.DisplayDialogComplex("Failed to load window layout", "This can happen if layout contains custom windows and there are compile errors in the project.", "Load Default Layout", "Quit", "Revert Factory Settings"))
                {
                case 0:
                    WindowLayout.LoadDefaultLayout();
                    break;

                case 1:
                    EditorApplication.Exit(0);
                    break;

                case 2:
                    WindowLayout.RevertFactorySettings();
                    break;
                }
                return(false);
            }
            finally
            {
                ContainerWindow.SetFreezeDisplay(false);
                if (Path.GetExtension(path) == ".wlt")
                {
                    Toolbar.lastLoadedLayoutName = Path.GetFileNameWithoutExtension(path);
                }
                else
                {
                    Toolbar.lastLoadedLayoutName = null;
                }
            }
            return(true);
        }