private static EditorWindow GetWindowWithRectPrivate(Type t, Rect rect, bool utility, string title) { UnityEngine.Object[] array = Resources.FindObjectsOfTypeAll(t); EditorWindow editorWindow = (array.Length <= 0) ? null : ((EditorWindow)array[0]); if (!editorWindow) { editorWindow = (ScriptableObject.CreateInstance(t) as EditorWindow); editorWindow.minSize = new Vector2(rect.width, rect.height); editorWindow.maxSize = new Vector2(rect.width, rect.height); editorWindow.position = rect; if (title != null) { editorWindow.titleContent = new GUIContent(title); } if (utility) { editorWindow.ShowUtility(); } else { editorWindow.Show(); } } else { editorWindow.Focus(); } return(editorWindow); }
// Returns the first EditorWindow of type /t/ which is currently on the screen. static EditorWindow GetWindowWithRectPrivate(System.Type t, Rect rect, bool utility, string title) { UnityEngine.Object[] wins = Resources.FindObjectsOfTypeAll(t); EditorWindow win = wins.Length > 0 ? (EditorWindow)(wins[0]) : null; if (!win) { win = ScriptableObject.CreateInstance(t) as EditorWindow; win.minSize = new Vector2(rect.width, rect.height); win.maxSize = new Vector2(rect.width, rect.height); win.position = rect; if (title != null) { win.titleContent = new GUIContent(title); } if (utility) { win.ShowUtility(); } else { win.Show(); } } else { win.Focus(); } return(win); }
private static EditorWindow GetWindowPrivate(System.Type t, bool utility, string title, bool focus) { UnityEngine.Object[] objectsOfTypeAll = Resources.FindObjectsOfTypeAll(t); EditorWindow editorWindow = objectsOfTypeAll.Length <= 0 ? (EditorWindow)null : (EditorWindow)objectsOfTypeAll[0]; if (!(bool)((UnityEngine.Object)editorWindow)) { editorWindow = ScriptableObject.CreateInstance(t) as EditorWindow; if (title != null) { editorWindow.titleContent = new GUIContent(title); } if (utility) { editorWindow.ShowUtility(); } else { editorWindow.Show(); } } else if (focus) { editorWindow.Show(); editorWindow.Focus(); } return(editorWindow); }
public static EditorWindow GetWindow(Type t, [DefaultValue("false")] bool utility, [DefaultValue("null")] string title, [DefaultValue("true")] bool focus) { UnityEngine.Object[] array = Resources.FindObjectsOfTypeAll(t); EditorWindow editorWindow = (array.Length <= 0) ? null : ((EditorWindow)array[0]); if (!editorWindow) { editorWindow = (ScriptableObject.CreateInstance(t) as EditorWindow); if (title != null) { editorWindow.title = title; } if (utility) { editorWindow.ShowUtility(); } else { editorWindow.Show(); } } else { if (focus) { editorWindow.Show(); editorWindow.Focus(); } } return(editorWindow); }
// Returns the first EditorWindow of type /t/ which is currently on the screen. static EditorWindow GetWindowPrivate(System.Type t, bool utility, string title, bool focus) { UnityEngine.Object[] wins = Resources.FindObjectsOfTypeAll(t); EditorWindow win = wins.Length > 0 ? (EditorWindow)(wins[0]) : null; if (!win) { win = ScriptableObject.CreateInstance(t) as EditorWindow; if (title != null) { win.titleContent = new GUIContent(title); } if (utility) { win.ShowUtility(); } else { win.Show(); } } else if (focus) { win.Show(); // For some corner cases in saved layouts, the window can be in an unvisible state. // Since the caller asked for focus, it's fair to assume he wants it always to be visible. (case 586743) win.Focus(); } return(win); }
public static EditorWindow GetWindowWithRect(Type t, Rect rect, [DefaultValue("false")] bool utility, [DefaultValue("null")] string title) { UnityEngine.Object[] array = Resources.FindObjectsOfTypeAll(t); EditorWindow editorWindow = (array.Length <= 0) ? null : ((EditorWindow)array[0]); if (!editorWindow) { editorWindow = (ScriptableObject.CreateInstance(t) as EditorWindow); editorWindow.minSize = new Vector2(rect.width, rect.height); editorWindow.maxSize = new Vector2(rect.width, rect.height); editorWindow.position = rect; if (title != null) { editorWindow.title = title; } if (utility) { editorWindow.ShowUtility(); } else { editorWindow.Show(); } } else { editorWindow.Focus(); } return(editorWindow); }
private static EditorWindow GetWindowPrivate(Type t, bool utility, string title, bool focus) { UnityEngine.Object[] array = Resources.FindObjectsOfTypeAll(t); EditorWindow editorWindow = (array.Length <= 0) ? null : ((EditorWindow)array[0]); if (!editorWindow) { editorWindow = (ScriptableObject.CreateInstance(t) as EditorWindow); if (title != null) { editorWindow.titleContent = new GUIContent(title); } if (utility) { editorWindow.ShowUtility(); } else { editorWindow.Show(); } } else if (focus) { editorWindow.Show(); editorWindow.Focus(); } return(editorWindow); }
private static EditorWindow GetWindowWithRectPrivate(System.Type t, Rect rect, bool utility, string title) { UnityEngine.Object[] objectsOfTypeAll = Resources.FindObjectsOfTypeAll(t); EditorWindow editorWindow = objectsOfTypeAll.Length <= 0 ? (EditorWindow)null : (EditorWindow)objectsOfTypeAll[0]; if (!(bool)((UnityEngine.Object)editorWindow)) { editorWindow = ScriptableObject.CreateInstance(t) as EditorWindow; editorWindow.minSize = new Vector2(rect.width, rect.height); editorWindow.maxSize = new Vector2(rect.width, rect.height); editorWindow.position = rect; if (title != null) { editorWindow.titleContent = new GUIContent(title); } if (utility) { editorWindow.ShowUtility(); } else { editorWindow.Show(); } } else { editorWindow.Focus(); } return(editorWindow); }
public static void MaximizePresent(EditorWindow win) { ContainerWindow.SetFreezeDisplay(true); win.Focus(); CheckWindowConsistency(); win.m_Parent.window.DisplayAllViews(); win.m_Parent.MakeVistaDWMHappyDance(); ContainerWindow.SetFreezeDisplay(false); }
public static void MaximizePresent(EditorWindow win, View rootSplit) { ContainerWindow.SetFreezeDisplay(true); UnityEngine.Object.DestroyImmediate((UnityEngine.Object)rootSplit, true); win.Focus(); WindowLayout.CheckWindowConsistency(); win.m_Parent.window.DisplayAllViews(); win.m_Parent.MakeVistaDWMHappyDance(); ContainerWindow.SetFreezeDisplay(false); }
public static void FocusWindowIfItsOpen(Type t) { Object[] objArray = Resources.FindObjectsOfTypeAll(t); EditorWindow window = (objArray.Length <= 0) ? null : (objArray[0] as EditorWindow); if (window != null) { window.Focus(); } }
public static void FocusWindowIfItsOpen(Type t) { UnityEngine.Object[] array = Resources.FindObjectsOfTypeAll(t); EditorWindow editorWindow = (array.Length <= 0) ? null : (array[0] as EditorWindow); if (editorWindow) { editorWindow.Focus(); } }
// Focuses the first found EditorWindow of specified type if it is open. public static void FocusWindowIfItsOpen(System.Type t) { UnityEngine.Object[] wins = Resources.FindObjectsOfTypeAll(t); EditorWindow win = wins.Length > 0 ? (wins[0] as EditorWindow) : null; if (win) { win.Focus(); } }
/// <summary> /// <para>Focuses the first found EditorWindow of specified type if it is open.</para> /// </summary> /// <param name="t">The type of the window. Must derive from EditorWindow.</param> public static void FocusWindowIfItsOpen(System.Type t) { UnityEngine.Object[] objectsOfTypeAll = Resources.FindObjectsOfTypeAll(t); EditorWindow editorWindow = objectsOfTypeAll.Length <= 0 ? (EditorWindow)null : objectsOfTypeAll[0] as EditorWindow; if (!(bool)((UnityEngine.Object)editorWindow)) { return; } editorWindow.Focus(); }
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 bool PerformDrop(EditorWindow dropWindow, DropInfo dropInfo, Vector2 screenPos) { var extraInfo = dropInfo.userData as ExtraDropInfo; var rootWindow = extraInfo.rootWindow; var edge = extraInfo.edge; var dropIndex = extraInfo.index; var dropRect = dropInfo.rect; var beginning = (edge & ViewEdge.Before) != 0; var wantsVertical = (edge & ViewEdge.FitsVertical) != 0; SplitView parentForDrop = null; if (vertical == wantsVertical || children.Length < 2) { // Current view can accommodate desired drop if (!beginning) { if (rootWindow) { dropIndex = children.Length; } else { ++dropIndex; } } parentForDrop = this; } else if (rootWindow) { // Docking to a window: need to insert a parent var newParent = ScriptableObject.CreateInstance <SplitView>(); newParent.position = position; if (window.rootView == this) { window.rootView = newParent; } else // Main window has MainView as its root { parent.AddChild(newParent, parent.IndexOfChild(this)); } newParent.AddChild(this); position = new Rect(Vector2.zero, position.size); dropIndex = beginning ? 0 : 1; parentForDrop = newParent; } else { // Docking in a view: need to insert a child var newChild = ScriptableObject.CreateInstance <SplitView>(); newChild.AddChild(children[dropIndex]); AddChild(newChild, dropIndex); newChild.position = newChild.children[0].position; newChild.children[0].position = new Rect(Vector2.zero, newChild.position.size); dropIndex = beginning ? 0 : 1; parentForDrop = newChild; } dropRect.position = dropRect.position - screenPosition.position; var newDockArea = ScriptableObject.CreateInstance <DockArea>(); parentForDrop.vertical = wantsVertical; parentForDrop.MakeRoomForRect(dropRect); parentForDrop.AddChild(newDockArea, dropIndex); newDockArea.position = dropRect; DockArea.s_OriginalDragSource.RemoveTab(dropWindow, killIfEmpty: true, sendEvents: false); dropWindow.m_Parent = newDockArea; newDockArea.AddTab(dropWindow, sendPaneEvents: false); Reflow(); RecalcMinMaxAndReflowAll(this); newDockArea.MakeVistaDWMHappyDance(); dropWindow.Focus(); return(true); }
public override void Update(CameraState cameraState, Camera cam, EditorWindow window) { Event evt = Event.current; if (evt.type == EventType.MouseUp) { m_CurrentViewTool = ViewTool.None; } if (evt.type == EventType.MouseDown) { int button = evt.button; bool controlKeyOnMac = (evt.control && Application.platform == RuntimePlatform.OSXEditor); var rightMouseButton = false; if (button == 2) { m_CurrentViewTool = ViewTool.Pan; } else if ((button <= 0 && controlKeyOnMac) || (button == 1 && evt.alt)) { m_CurrentViewTool = ViewTool.Zoom; m_StartZoom = cameraState.viewSize.value; m_ZoomSpeed = Mathf.Max(Mathf.Abs(m_StartZoom), .3f); m_TotalMotion = 0; rightMouseButton = button == 1; } else if (button <= 0) { m_CurrentViewTool = ViewTool.Orbit; } else if (button == 1 && !evt.alt) { m_CurrentViewTool = ViewTool.FPS; rightMouseButton = true; } // see also SceneView.HandleClickAndDragToFocus() if (rightMouseButton && Application.platform == RuntimePlatform.OSXEditor) { window.Focus(); } } var id = GUIUtility.GetControlID(FocusType.Passive); using (var inputSamplingScope = new CameraFlyModeContext.InputSamplingScope(m_CameraFlyModeContext, m_CurrentViewTool, id)) { if (inputSamplingScope.inputVectorChanged) { m_FlySpeed = 0; } m_Motion = inputSamplingScope.currentInputVector; } switch (evt.type) { case EventType.ScrollWheel: HandleCameraScrollWheel(cameraState); break; case EventType.MouseUp: HandleCameraMouseUp(); break; case EventType.MouseDrag: HandleCameraMouseDrag(cameraState, cam); break; case EventType.KeyDown: HandleCameraKeyDown(); break; case EventType.Layout: { Vector3 motion = GetMovementDirection(); if (motion.sqrMagnitude != 0) { cameraState.pivot.value = cameraState.pivot.value + cameraState.rotation.value * motion; } } break; } }
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 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 parent1 = win.m_Parent; if ((UnityEngine.Object)parent1 == (UnityEngine.Object)null) { UnityEngine.Debug.LogError((object)"Host view was not found"); WindowLayout.RevertFactorySettings(); } else { UnityEngine.Object[] objectArray = InternalEditorUtility.LoadSerializedFileAndForget(Path.Combine(WindowLayout.layoutsProjectPath, "CurrentMaximizeLayout.dwlt")); if (objectArray.Length < 2) { UnityEngine.Debug.Log((object)"Maximized serialized file backup not found"); WindowLayout.RevertFactorySettings(); } else { SplitView splitView = objectArray[0] as SplitView; EditorWindow pane = objectArray[1] as EditorWindow; if ((UnityEngine.Object)splitView == (UnityEngine.Object)null) { UnityEngine.Debug.Log((object)"Maximization failed because the root split view was not found"); WindowLayout.RevertFactorySettings(); } else { ContainerWindow window = win.m_Parent.window; if ((UnityEngine.Object)window == (UnityEngine.Object)null) { UnityEngine.Debug.Log((object)"Maximization failed because the root split view has no container window"); WindowLayout.RevertFactorySettings(); } else { try { ContainerWindow.SetFreezeDisplay(true); if (!(bool)((UnityEngine.Object)parent1.parent)) { throw new Exception(); } int idx1 = parent1.parent.IndexOfChild((View)parent1); Rect position = parent1.position; View parent2 = parent1.parent; parent2.RemoveChild(idx1); parent2.AddChild((View)splitView, idx1); splitView.position = position; DockArea parent3 = pane.m_Parent as DockArea; int idx2 = parent3.m_Panes.IndexOf(pane); parent1.actualView = (EditorWindow)null; win.m_Parent = (HostView)null; parent3.AddTab(idx2, win); parent3.RemoveTab(pane); UnityEngine.Object.DestroyImmediate((UnityEngine.Object)pane); foreach (UnityEngine.Object @object in objectArray) { EditorWindow editorWindow = @object as EditorWindow; if ((UnityEngine.Object)editorWindow != (UnityEngine.Object)null) { editorWindow.MakeParentsSettingsMatchMe(); } } parent2.Initialize(parent2.window); parent2.position = parent2.position; splitView.Reflow(); UnityEngine.Object.DestroyImmediate((UnityEngine.Object)parent1); win.Focus(); window.DisplayAllViews(); win.m_Parent.MakeVistaDWMHappyDance(); } catch (Exception ex) { UnityEngine.Debug.Log((object)("Maximization failed: " + (object)ex)); WindowLayout.RevertFactorySettings(); } try { if (Application.platform != RuntimePlatform.OSXEditor || !SystemInfo.operatingSystem.Contains("10.7") || !SystemInfo.graphicsDeviceVendor.Contains("ATI")) { return; } foreach (GUIView guiView in Resources.FindObjectsOfTypeAll(typeof(GUIView))) { guiView.Repaint(); } } finally { ContainerWindow.SetFreezeDisplay(false); } } } } } }