OnResize() private méthode

private OnResize ( ) : void
Résultat void
Exemple #1
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();
        }
Exemple #2
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();
        }
Exemple #3
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();
        }
Exemple #4
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();
        }
        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);
        }
        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);
        }
 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;
 }
Exemple #9
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);
        }