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