Inheritance: GUIView
        internal string GetWindowID()
        {
            HostView v = rootView as HostView;

            if (v == null && rootView is SplitView && rootView.children.Length > 0)
            {
                v = rootView.children[0] as HostView;
            }

            if (v == null || !v.actualView)
            {
                return(rootView.GetType().ToString());
            }

            if (rootView.children.Length > 0)
            {
                var dockArea = rootView.children.FirstOrDefault(c => c is DockArea) as DockArea;
                if (dockArea && dockArea.m_Panes.Count > 0)
                {
                    return((m_ShowMode == (int)ShowMode.Utility || m_ShowMode == (int)ShowMode.AuxWindow) ? v.actualView.GetType().ToString()
                        : dockArea.m_Panes[0].GetType().ToString());
                }
            }

            return(v.actualView.GetType().ToString());
        }
Exemple #2
0
        private string NotDockedWindowID()
        {
            if (IsNotDocked())
            {
                HostView v = rootView as HostView;

                if (v == null)
                {
                    if (rootView is SplitView)
                    {
                        v = (HostView)rootView.children[0];
                    }
                    else
                    {
                        return(rootView.GetType().ToString());
                    }
                }


                return((m_ShowMode == (int)ShowMode.Utility || m_ShowMode == (int)ShowMode.AuxWindow) ? v.actualView.GetType().ToString()
                    : ((DockArea)rootView.children[0]).m_Panes[0].GetType().ToString());
            }

            return(null);
        }
Exemple #3
0
        private static void OneShotUxmlLiveReload()
        {
            try
            {
                Dictionary <int, Panel> .Enumerator panelsIterator = UIElementsUtility.GetPanelsIterator();
                while (panelsIterator.MoveNext())
                {
                    KeyValuePair <int, Panel> current = panelsIterator.Current;
                    HostView hostView = current.Value.ownerObject as HostView;
                    if (hostView != null && hostView.actualView != null)
                    {
                        hostView.Reload(hostView.actualView);
                    }
                }
            }
            catch (Exception exception)
            {
                Debug.LogException(exception);
            }
            Delegate arg_96_0 = EditorApplication.update;

            if (RetainedMode.< > f__mg$cache3 == null)
            {
                RetainedMode.< > f__mg$cache3 = new EditorApplication.CallbackFunction(RetainedMode.OneShotUxmlLiveReload);
            }
            EditorApplication.update = (EditorApplication.CallbackFunction)Delegate.Remove(arg_96_0, RetainedMode.< > f__mg$cache3);
        }
        private static EditorWindow GetEditorWindow(GUIView view)
        {
            HostView hostView = view as HostView;

            if (hostView != null)
            {
                return(hostView.actualView);
            }
            return(null);
        }
        private static EditorWindow GetEditorWindow(GUIView view)
        {
            HostView hostView = view as HostView;

            if ((UnityEngine.Object)hostView != (UnityEngine.Object)null)
            {
                return(hostView.actualView);
            }
            return((EditorWindow)null);
        }
Exemple #6
0
        private static EditorWindow GetEditorWindow(GUIView view)
        {
            HostView view2 = view as HostView;

            if (view2 != null)
            {
                return(view2.actualView);
            }
            return(null);
        }
        static string GetGUIViewName(GUIView view)
        {
            HostView host = view as HostView;

            if (host != null)
            {
                return(host.actualView.GetType().Name);
            }
            return("Window");
        }
        private static string GetGUIViewName(GUIView view)
        {
            HostView hostView = view as HostView;

            if ((Object)hostView != (Object)null)
            {
                return(hostView.actualView.GetType().Name);
            }
            return("Window");
        }
Exemple #9
0
        private static string GetGUIViewName(GUIView view)
        {
            HostView view2 = view as HostView;

            if (view2 != null)
            {
                return(view2.actualView.GetType().Name);
            }
            return("Window");
        }
Exemple #10
0
 public void ShowPopup()
 {
     if (this.m_Parent == null)
     {
         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.ShowPopup();
     }
 }
        private static EditorWindow GetEditorWindow(GUIView view)
        {
            HostView     hostView = view as HostView;
            EditorWindow result;

            if (hostView != null)
            {
                result = hostView.actualView;
            }
            else
            {
                result = null;
            }
            return(result);
        }
Exemple #12
0
        private static string GetGUIViewName(GUIView view)
        {
            HostView hostView = view as HostView;
            string   result;

            if (hostView != null)
            {
                result = hostView.actualView.GetType().Name;
            }
            else
            {
                result = "Window";
            }
            return(result);
        }
Exemple #13
0
 public void InvokeOnGUI(Rect onGUIPosition)
 {
     if (Unsupported.IsDeveloperMode() && this.actualView != null && Event.current.type == EventType.KeyUp && Event.current.keyCode == KeyCode.F5)
     {
         this.Reload(this.actualView);
     }
     else
     {
         base.DoWindowDecorationStart();
         GUIStyle gUIStyle = "dockareaoverlay";
         if (this.actualView is GameView)
         {
             GUI.Box(onGUIPosition, GUIContent.none, gUIStyle);
         }
         HostView.BeginOffsetArea(new Rect(onGUIPosition.x + 2f, onGUIPosition.y + 17f, onGUIPosition.width - 4f, onGUIPosition.height - 17f - 2f), GUIContent.none, "TabWindowBackground");
         EditorGUIUtility.ResetGUIState();
         bool flag = false;
         try
         {
             this.Invoke("OnGUI");
         }
         catch (TargetInvocationException ex)
         {
             if (ex.InnerException is ExitGUIException)
             {
                 flag = true;
             }
             throw;
         }
         finally
         {
             if (!flag)
             {
                 if (this.actualView != null && this.actualView.m_FadeoutTime != 0f && Event.current != null && Event.current.type == EventType.Repaint)
                 {
                     this.actualView.DrawNotification();
                 }
                 HostView.EndOffsetArea();
                 EditorGUIUtility.ResetGUIState();
                 base.DoWindowDecorationEnd();
                 if (Event.current.type == EventType.Repaint)
                 {
                     gUIStyle.Draw(onGUIPosition, GUIContent.none, 0);
                 }
             }
         }
     }
 }
Exemple #14
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();
     }
 }
 private string NotDockedWindowID()
 {
     if (this.IsNotDocked())
     {
         HostView hostView = this.mainView as HostView;
         if (hostView == null)
         {
             if (!(this.mainView is SplitView))
             {
                 return(this.mainView.GetType().ToString());
             }
             hostView = (HostView)this.mainView.children[0];
         }
         return((this.m_ShowMode != 2 && this.m_ShowMode != 5) ? ((DockArea)this.mainView.children[0]).m_Panes[0].GetType().ToString() : hostView.actualView.GetType().ToString());
     }
     return(null);
 }
 public static void AddSplitViewAndChildrenRecurse(View splitview, ArrayList list)
 {
     list.Add(splitview);
     DockArea area = splitview as DockArea;
     if (area != null)
     {
         list.AddRange(area.m_Panes);
     }
     HostView view = splitview as DockArea;
     if (view != null)
     {
         list.Add(area.actualView);
     }
     foreach (View view2 in splitview.children)
     {
         AddSplitViewAndChildrenRecurse(view2, list);
     }
 }
        // Used for popup style windows.
        internal void ShowPopupWithMode(ShowMode mode, bool giveFocus)
        {
            if (m_Parent == null)
            {
                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.ShowPopupWithMode(mode, giveFocus);
            }
        }
Exemple #18
0
        /// <summary>
        ///   <para>Shows an Editor window using popup-style framing.</para>
        /// </summary>
        public void ShowPopup()
        {
            if (!((UnityEngine.Object) this.m_Parent == (UnityEngine.Object)null))
            {
                return;
            }
            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.ShowPopup();
        }
        public static void AddSplitViewAndChildrenRecurse(View splitview, ArrayList list)
        {
            list.Add(splitview);
            DockArea dock = splitview as DockArea;

            if (dock != null)
            {
                list.AddRange(dock.m_Panes);

                HostView host = splitview as DockArea;
                if (host != null)
                {
                    list.Add(dock.actualView);
                }
            }

            foreach (View child in splitview.children)
            {
                AddSplitViewAndChildrenRecurse(child, list);
            }
        }
Exemple #20
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();
        }
Exemple #21
0
        private string NotDockedWindowID()
        {
            if (!this.IsNotDocked())
            {
                return((string)null);
            }
            HostView hostView = this.mainView as HostView;

            if ((Object)hostView == (Object)null)
            {
                if (!(this.mainView is SplitView))
                {
                    return(this.mainView.GetType().ToString());
                }
                hostView = (HostView)this.mainView.children[0];
            }
            if (this.m_ShowMode == 2 || this.m_ShowMode == 5)
            {
                return(hostView.actualView.GetType().ToString());
            }
            return(((DockArea)this.mainView.children[0]).m_Panes[0].GetType().ToString());
        }
        internal string GetWindowID()
        {
            HostView v = rootView as HostView;

            if (v == null && rootView is SplitView && rootView.children.Length > 0)
            {
                v = rootView.children[0] as HostView;
            }

            if (v == null || !v.actualView)
            {
                return(rootView.GetType().ToString());
            }

            if (rootView.children.Length > 0)
            {
                return((m_ShowMode == (int)ShowMode.Utility || m_ShowMode == (int)ShowMode.AuxWindow) ? v.actualView.GetType().ToString()
                    : ((DockArea)rootView.children[0]).m_Panes[0].GetType().ToString());
            }

            return(v.actualView.GetType().ToString());
        }
        public static void AddSplitViewAndChildrenRecurse(View splitview, ArrayList list)
        {
            list.Add(splitview);
            DockArea dockArea = splitview as DockArea;

            if (dockArea != null)
            {
                list.AddRange(dockArea.m_Panes);
            }
            HostView x = splitview as DockArea;

            if (x != null)
            {
                list.Add(dockArea.actualView);
            }
            View[] children = splitview.children;
            for (int i = 0; i < children.Length; i++)
            {
                View splitview2 = children[i];
                WindowLayout.AddSplitViewAndChildrenRecurse(splitview2, list);
            }
        }
        public static void FocusProjectWindow()
        {
            ProjectBrowser projectBrowser = null;
            HostView       hostView       = GUIView.focusedView as HostView;

            if (hostView != null && hostView.actualView is ProjectBrowser)
            {
                projectBrowser = (hostView.actualView as ProjectBrowser);
            }
            if (projectBrowser == null)
            {
                UnityEngine.Object[] array = Resources.FindObjectsOfTypeAll(typeof(ProjectBrowser));
                if (array.Length > 0)
                {
                    projectBrowser = (array[0] as ProjectBrowser);
                }
            }
            if (projectBrowser != null)
            {
                projectBrowser.Focus();
                Event e = EditorGUIUtility.CommandEvent("FocusProjectWindow");
                projectBrowser.SendEvent(e);
            }
        }
        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();
            }
        }
Exemple #26
0
        public void OldOnGUI()
        {
            base.ClearBackground();
            EditorGUIUtility.ResetGUIState();
            SplitView splitView = base.parent as SplitView;

            if (Event.current.type == EventType.Repaint && splitView)
            {
                View child = this;
                while (splitView)
                {
                    int controlID = splitView.controlID;
                    if (controlID == GUIUtility.hotControl || GUIUtility.hotControl == 0)
                    {
                        int num = splitView.IndexOfChild(child);
                        if (splitView.vertical)
                        {
                            if (num != 0)
                            {
                                EditorGUIUtility.AddCursorRect(new Rect(0f, 0f, base.position.width, 5f), MouseCursor.SplitResizeUpDown, controlID);
                            }
                            if (num != splitView.children.Length - 1)
                            {
                                EditorGUIUtility.AddCursorRect(new Rect(0f, base.position.height - 5f, base.position.width, 5f), MouseCursor.SplitResizeUpDown, controlID);
                            }
                        }
                        else
                        {
                            if (num != 0)
                            {
                                EditorGUIUtility.AddCursorRect(new Rect(0f, 0f, 5f, base.position.height), MouseCursor.SplitResizeLeftRight, controlID);
                            }
                            if (num != splitView.children.Length - 1)
                            {
                                EditorGUIUtility.AddCursorRect(new Rect(base.position.width - 5f, 0f, 5f, base.position.height), MouseCursor.SplitResizeLeftRight, controlID);
                            }
                        }
                    }
                    child     = splitView;
                    splitView = (splitView.parent as SplitView);
                }
                splitView = (base.parent as SplitView);
            }
            bool flag = false;

            if (base.window.rootView.GetType() != typeof(MainView))
            {
                flag = true;
                if (base.windowPosition.y == 0f)
                {
                    this.background = "dockareaStandalone";
                }
                else
                {
                    this.background = "dockarea";
                }
            }
            else
            {
                this.background = "dockarea";
            }
            if (splitView)
            {
                Event @event = new Event(Event.current);
                @event.mousePosition += new Vector2(base.position.x, base.position.y);
                splitView.SplitGUI(@event);
                if (@event.type == EventType.Used)
                {
                    Event.current.Use();
                }
            }
            Rect rect = this.background.margin.Remove(new Rect(0f, 0f, base.position.width, base.position.height));

            rect.x = (float)this.background.margin.left;
            rect.y = (float)this.background.margin.top;
            Rect  windowPosition = base.windowPosition;
            float num2           = 2f;

            if (windowPosition.x == 0f)
            {
                rect.x     -= num2;
                rect.width += num2;
            }
            if (windowPosition.xMax == base.window.position.width)
            {
                rect.width += num2;
            }
            if (windowPosition.yMax == base.window.position.height)
            {
                rect.height += ((!flag) ? 2f : 2f);
            }
            if (Event.current.type == EventType.Repaint)
            {
                this.background.Draw(rect, GUIContent.none, 0);
            }
            if (this.tabStyle == null)
            {
                this.tabStyle = "dragtab";
            }
            if (this.m_Panes.Count > 0)
            {
                HostView.BeginOffsetArea(new Rect(rect.x + 2f, rect.y + 17f, rect.width - 4f, rect.height - 17f - 2f), GUIContent.none, "TabWindowBackground");
                Vector2 vector = GUIUtility.GUIToScreenPoint(Vector2.zero);
                Rect    pos    = base.borderSize.Remove(base.position);
                pos.x = vector.x;
                pos.y = vector.y;
                this.m_Panes[this.selected].m_Pos = pos;
                HostView.EndOffsetArea();
            }
            this.DragTab(new Rect(rect.x + 1f, rect.y, rect.width - 40f, 17f), this.tabStyle);
            this.tabStyle = "dragtab";
            base.ShowGenericMenu();
            if (this.m_Panes.Count > 0)
            {
                base.InvokeOnGUI(rect);
            }
            EditorGUI.ShowRepaints();
            Highlighter.ControlHighlightGUI(this);
        }
 public static void Unmaximize(EditorWindow win)
 {
     HostView parent = win.m_Parent;
     if (parent == null)
     {
         UnityEngine.Debug.LogError("Host view was not found");
         RevertFactorySettings();
     }
     else
     {
         UnityEngine.Object[] objArray = InternalEditorUtility.LoadSerializedFileAndForget(Path.Combine(layoutsProjectPath, "CurrentMaximizeLayout.dwlt"));
         if (objArray.Length < 2)
         {
             UnityEngine.Debug.Log("Maximized serialized file backup not found");
             RevertFactorySettings();
         }
         else
         {
             SplitView child = objArray[0] as SplitView;
             EditorWindow item = objArray[1] as EditorWindow;
             if (child == null)
             {
                 UnityEngine.Debug.Log("Maximization failed because the root split view was not found");
                 RevertFactorySettings();
             }
             else
             {
                 ContainerWindow window = win.m_Parent.window;
                 if (window == null)
                 {
                     UnityEngine.Debug.Log("Maximization failed because the root split view has no container window");
                     RevertFactorySettings();
                 }
                 else
                 {
                     try
                     {
                         ContainerWindow.SetFreezeDisplay(true);
                         if (parent.parent == null)
                         {
                             throw new Exception();
                         }
                         int idx = parent.parent.IndexOfChild(parent);
                         Rect position = parent.position;
                         View view3 = parent.parent;
                         view3.RemoveChild(idx);
                         view3.AddChild(child, idx);
                         child.position = position;
                         DockArea area = item.m_Parent as DockArea;
                         int index = area.m_Panes.IndexOf(item);
                         parent.actualView = null;
                         win.m_Parent = null;
                         area.AddTab(index, win);
                         area.RemoveTab(item);
                         UnityEngine.Object.DestroyImmediate(item);
                         foreach (UnityEngine.Object obj2 in objArray)
                         {
                             EditorWindow window3 = obj2 as EditorWindow;
                             if (window3 != null)
                             {
                                 window3.MakeParentsSettingsMatchMe();
                             }
                         }
                         view3.Initialize(view3.window);
                         view3.position = view3.position;
                         child.Reflow();
                         UnityEngine.Object.DestroyImmediate(parent);
                         win.Focus();
                         window.DisplayAllViews();
                         win.m_Parent.MakeVistaDWMHappyDance();
                     }
                     catch (Exception exception)
                     {
                         UnityEngine.Debug.Log("Maximization failed: " + exception);
                         RevertFactorySettings();
                     }
                     try
                     {
                         if (((Application.platform == RuntimePlatform.OSXEditor) && SystemInfo.operatingSystem.Contains("10.7")) && SystemInfo.graphicsDeviceVendor.Contains("ATI"))
                         {
                             foreach (GUIView view4 in UnityEngine.Resources.FindObjectsOfTypeAll(typeof(GUIView)))
                             {
                                 view4.Repaint();
                             }
                         }
                     }
                     finally
                     {
                         ContainerWindow.SetFreezeDisplay(false);
                     }
                 }
             }
         }
     }
 }
        public static void Unmaximize(EditorWindow win)
        {
            HostView parent = win.m_Parent;

            if (parent == null)
            {
                UnityEngine.Debug.LogError("Host view was not found");
                WindowLayout.RevertFactorySettings();
            }
            else
            {
                UnityEngine.Object[] array = InternalEditorUtility.LoadSerializedFileAndForget(Path.Combine(WindowLayout.layoutsProjectPath, "CurrentMaximizeLayout.dwlt"));
                if (array.Length < 2)
                {
                    UnityEngine.Debug.Log("Maximized serialized file backup not found");
                    WindowLayout.RevertFactorySettings();
                }
                else
                {
                    SplitView    splitView    = array[0] as SplitView;
                    EditorWindow editorWindow = array[1] as EditorWindow;
                    if (splitView == null)
                    {
                        UnityEngine.Debug.Log("Maximization failed because the root split view was not found");
                        WindowLayout.RevertFactorySettings();
                    }
                    else
                    {
                        ContainerWindow window = win.m_Parent.window;
                        if (window == null)
                        {
                            UnityEngine.Debug.Log("Maximization failed because the root split view has no container window");
                            WindowLayout.RevertFactorySettings();
                        }
                        else
                        {
                            try
                            {
                                ContainerWindow.SetFreezeDisplay(true);
                                if (!parent.parent)
                                {
                                    throw new Exception();
                                }
                                int  idx      = parent.parent.IndexOfChild(parent);
                                Rect position = parent.position;
                                View parent2  = parent.parent;
                                parent2.RemoveChild(idx);
                                parent2.AddChild(splitView, idx);
                                splitView.position = position;
                                DockArea dockArea = editorWindow.m_Parent as DockArea;
                                int      idx2     = dockArea.m_Panes.IndexOf(editorWindow);
                                parent.actualView = null;
                                win.m_Parent      = null;
                                dockArea.AddTab(idx2, win);
                                dockArea.RemoveTab(editorWindow);
                                UnityEngine.Object.DestroyImmediate(editorWindow);
                                UnityEngine.Object[] array2 = array;
                                for (int i = 0; i < array2.Length; i++)
                                {
                                    UnityEngine.Object @object       = array2[i];
                                    EditorWindow       editorWindow2 = @object as EditorWindow;
                                    if (editorWindow2 != null)
                                    {
                                        editorWindow2.MakeParentsSettingsMatchMe();
                                    }
                                }
                                parent2.Initialize(parent2.window);
                                parent2.position = parent2.position;
                                splitView.Reflow();
                                UnityEngine.Object.DestroyImmediate(parent);
                                win.Focus();
                                window.DisplayAllViews();
                                win.m_Parent.MakeVistaDWMHappyDance();
                            }
                            catch (Exception arg)
                            {
                                UnityEngine.Debug.Log("Maximization failed: " + arg);
                                WindowLayout.RevertFactorySettings();
                            }
                            try
                            {
                                if (Application.platform == RuntimePlatform.OSXEditor && SystemInfo.operatingSystem.Contains("10.7") && SystemInfo.graphicsDeviceVendor.Contains("ATI"))
                                {
                                    UnityEngine.Object[] array3 = Resources.FindObjectsOfTypeAll(typeof(GUIView));
                                    for (int j = 0; j < array3.Length; j++)
                                    {
                                        GUIView gUIView = (GUIView)array3[j];
                                        gUIView.Repaint();
                                    }
                                }
                            }
                            finally
                            {
                                ContainerWindow.SetFreezeDisplay(false);
                            }
                        }
                    }
                }
            }
        }
        public static void Unmaximize(EditorWindow win)
        {
            HostView maximizedHostView = win.m_Parent;

            if (maximizedHostView == null)
            {
                Debug.LogError("Host view was not found");
                RevertFactorySettings();
                return;
            }

            UnityObject[] newWindows = InternalEditorUtility.LoadSerializedFileAndForget(Path.Combine(layoutsProjectPath, kMaximizeRestoreFile));

            if (newWindows.Length < 2)
            {
                Debug.Log("Maximized serialized file backup not found");
                RevertFactorySettings();
                return;
            }

            SplitView    oldRoot   = newWindows[0] as SplitView;
            EditorWindow oldWindow = newWindows[1] as EditorWindow;

            if (oldRoot == null)
            {
                Debug.Log("Maximization failed because the root split view was not found");
                RevertFactorySettings();
                return;
            }

            ContainerWindow parentWindow = win.m_Parent.window;

            if (parentWindow == null)
            {
                Debug.Log("Maximization failed because the root split view has no container window");
                RevertFactorySettings();
                return;
            }

            try
            {
                ContainerWindow.SetFreezeDisplay(true);

                // Put the loaded SplitView where the MaximizedHostView was
                if (maximizedHostView.parent)
                {
                    int  i      = maximizedHostView.parent.IndexOfChild(maximizedHostView);
                    Rect r      = maximizedHostView.position;
                    View parent = maximizedHostView.parent;
                    parent.RemoveChild(i);
                    parent.AddChild(oldRoot, i);
                    oldRoot.position = r;

                    // Move the Editor Window to the right spot in the
                    DockArea newDockArea = oldWindow.m_Parent as DockArea;

                    int oldDockAreaIndex = newDockArea.m_Panes.IndexOf(oldWindow);

                    maximizedHostView.actualView = null;
                    win.m_Parent = null;
                    newDockArea.AddTab(oldDockAreaIndex, win);
                    newDockArea.RemoveTab(oldWindow);
                    UnityObject.DestroyImmediate(oldWindow);

                    foreach (UnityObject o in newWindows)
                    {
                        EditorWindow curWin = o as EditorWindow;
                        if (curWin != null)
                        {
                            curWin.MakeParentsSettingsMatchMe();
                        }
                    }

                    parent.Initialize(parent.window);
                    //If parent window had to be resized, call this to make sure new size gets propagated
                    parent.position = parent.position;
                    oldRoot.Reflow();
                }
                else
                {
                    throw new System.Exception();
                }

                // Kill the maximizedMainView
                UnityObject.DestroyImmediate(maximizedHostView);

                win.Focus();

                parentWindow.DisplayAllViews();
                win.m_Parent.MakeVistaDWMHappyDance();
            }
            catch (System.Exception ex)
            {
                Debug.Log("Maximization failed: " + ex);
                RevertFactorySettings();
            }

            try
            {
                // Weird bug on AMD graphic cards under OSX Lion: Sometimes when unmaximizing we get stray white rectangles.
                // work around that by issueing an extra repaint (case 438764)
                if (Application.platform == RuntimePlatform.OSXEditor && SystemInfo.operatingSystem.Contains("10.7") && SystemInfo.graphicsDeviceVendor.Contains("ATI"))
                {
                    foreach (GUIView v in Resources.FindObjectsOfTypeAll(typeof(GUIView)))
                    {
                        v.Repaint();
                    }
                }
            }
            finally
            {
                ContainerWindow.SetFreezeDisplay(false);
            }
        }
        public static bool LoadWindowLayout(string path, bool newProjectLayoutWasCreated, bool setLastLoadedLayoutName, bool keepMainWindow)
        {
            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(keepMainWindow);

                ContainerWindow mainWindowToSetSize = null;
                ContainerWindow mainWindow          = null;

                UnityObject[] remainingContainers = Resources.FindObjectsOfTypeAll(typeof(ContainerWindow));
                foreach (ContainerWindow window in remainingContainers)
                {
                    if (mainWindow == null && window.showMode == ShowMode.MainWindow)
                    {
                        mainWindow = window;
                    }
                    else
                    {
                        window.Close();
                    }
                }

                // 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() + ", instanceID=" + o.GetInstanceID());
                            layoutLoadingIssue = true;
                            continue;
                        }
                    }
                    else
                    {
                        ContainerWindow cw = o as ContainerWindow;
                        if (cw != null && cw.rootView == null)
                        {
                            cw.Close();
                            UnityObject.DestroyImmediate(cw, true);
                            continue;
                        }

                        DockArea dockArea = o as DockArea;
                        if (dockArea != null && dockArea.m_Panes.Count == 0)
                        {
                            dockArea.Close(null);
                            UnityObject.DestroyImmediate(dockArea, true);
                            continue;
                        }

                        // Host views that donot hold any containers are not desirable at this stage
                        HostView hostview = o as HostView;
                        if (hostview != null && hostview.actualView == null)
                        {
                            UnityObject.DestroyImmediate(hostview, true);
                            continue;
                        }
                    }

                    newWindows.Add(o);
                }

                for (int i = 0; i < newWindows.Count; i++)
                {
                    ContainerWindow cur = newWindows[i] as ContainerWindow;
                    if (cur != null && cur.showMode == ShowMode.MainWindow)
                    {
                        if (mainWindow == null)
                        {
                            mainWindow = cur;
                        }
                        else
                        {
                            mainWindow.rootView = cur.rootView;
                            UnityObject.DestroyImmediate(cur, true);
                            cur           = mainWindow;
                            newWindows[i] = null;
                        }

                        if (mainWindowPosition.width != 0.0)
                        {
                            mainWindowToSetSize          = cur;
                            mainWindowToSetSize.position = mainWindowPosition;
                        }

                        break;
                    }
                }

                for (int i = 0; i < newWindows.Count; i++)
                {
                    UnityObject o = newWindows[i];
                    if (o == null)
                    {
                        continue;
                    }

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

                mainWindow.Show(mainWindow.showMode, loadPosition: true, displayImmediately: true, setFocus: true);

                // Show other windows
                for (int i = 0; i < newWindows.Count; i++)
                {
                    if (newWindows[i] == null)
                    {
                        continue;
                    }

                    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, loadPosition: false, displayImmediately: true, setFocus: true);
                    }
                }

                // Unmaximize maximized GameView if maximize on play is enabled
                GameView gameView = GetMaximizedWindow() as GameView;
                if (gameView != null && gameView.maximizeOnPlay)
                {
                    Unmaximize(gameView);
                }
            }
            catch (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 (setLastLoadedLayoutName && 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);
        }