private Rect getOffsetFromGameView() { var unityEditorType = Type.GetType("UnityEditor.GameView,UnityEditor"); var getMainGameViewMethod = unityEditorType.GetMethod("GetMainGameView", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static); UnityEditor.EditorWindow result = getMainGameViewMethod.Invoke(null, null) as UnityEditor.EditorWindow; return(result.position); }
public static void LoadAndStartRenderDocCapture(out UnityEditor.EditorWindow gameView) { UnityEditorInternal.RenderDoc.Load(); System.Reflection.Assembly assembly = typeof(UnityEditor.EditorWindow).Assembly; Type type = assembly.GetType("UnityEditor.GameView"); gameView = UnityEditor.EditorWindow.GetWindow(type); UnityEditorInternal.RenderDoc.BeginCaptureRenderDoc(gameView); }
private ScreenHelpers() { _hwnd = Win32Helpers.GetForegroundWindow(); _windowId = _hwnd.ToString(); #if UNITY_EDITOR _gameWindow = GetMainGameView(); #endif }
protected override string GetFocusedEditorWindowTitle() { #if UNITY_EDITOR UnityEditor.EditorWindow window = UnityEditor.EditorWindow.focusedWindow; return(window != null ? window.title : string.Empty); #else return(string.Empty); #endif }
public static Rect GetGameViewPosition() { #if UNITY_EDITOR System.Type T = System.Type.GetType("UnityEditor.GameView,UnityEditor"); //UnityEditor UnityEditor.EditorWindow gameview = UnityEditor.EditorWindow.GetWindow(T); return(gameview.position); // gameview.position; #else return(new Rect()); #endif }
private void FullScreen_OnValueChange(object sender, bool e) { #if UNITY_EDITOR UnityEditor.EditorWindow window = UnityEditor.EditorWindow.focusedWindow; // Assume the game view is focused. window.maximized = e; #else Screen.fullScreen = e; #endif }
public static void CenterOnMainWin(this UnityEditor.EditorWindow aWin) { var main = GetEditorMainWindowPos(); var pos = aWin.position; float w = (main.width - pos.width) * 0.5f; float h = (main.height - pos.height) * 0.5f; pos.x = main.x + w; pos.y = main.y + h; aWin.position = pos; }
static public void CloseReadme(Component component) { System.Type t = GetWindowType(); if (t != null) { UnityEditor.EditorWindow w = t.GetMethod("GetInstanceIfExists").Invoke(null, null) as UnityEditor.EditorWindow; if (w != null) { t.GetMethod("CloseIfOurs").Invoke(w, new object[] { component }); } } }
static void EnsureGameViewReference() { if (gameViewType == null) { gameViewType = Type.GetType("UnityEditor.GameView,UnityEditor"); } if (gameViewWindow == null) { gameViewWindow = UnityEditor.EditorWindow.GetWindowWithRect(gameViewType, new Rect(0, 0, 500, 500)); } }
public string GetFocusedEditorWindowTitle() { #if UNITY_EDITOR UnityEditor.EditorWindow window = UnityEditor.EditorWindow.focusedWindow; #if UNITY_2017_PLUS return(window != null ? window.titleContent.text : string.Empty); #else return(window != null ? window.title : string.Empty); #endif #else return(string.Empty); #endif }
public static void CenterOnApplicationWindow(this UnityEditor.EditorWindow window, Vector2?size = null) { var main = GetApplicationScreenRect(); var pos = window.position; pos.size = size.GetValueOrDefault(pos.size); float w = (main.width - pos.width) * 0.5f; float h = (main.height - pos.height) * 0.5f; pos.x = main.x + w; pos.y = main.y + h; window.position = pos; }
public static void CenterOnMainWinAsPortrait(this UnityEditor.EditorWindow aWin) { var main = GetEditorMainWindowPos(); var pos = aWin.position; pos.height = main.height - (main.height / 10); pos.width = (pos.height / 4) * 3; //main.width / 2; float w = (main.width - pos.width) * 0.5f; float h = (main.height - pos.height) * 0.5f; pos.x = main.x + w; pos.y = main.y + h; aWin.position = pos; }
private void Update() { //Unity sometimes generates an error when the window is closed from the OnGUI function. //So We close it here if (m_close) { Close(); if (LastFocusedWindow) { UnityEditor.EditorApplication.delayCall += LastFocusedWindow.Repaint; LastFocusedWindow = null; } } }
public void GUIUpdate(UnityEditor.EditorWindow window) { _zoom = Mathf.Lerp(previousZoom, targetZoom, (Time.realtimeSinceStartup - timeZoomRequested) / zoomEffectDuration); if (Event.current.type == EventType.Repaint) { if (_zoom == targetZoom) { IsZooming = false; } else { window.Repaint(); } } }
private void repaintGameView() { #if UNITY_EDITOR if (getMainGameViewMethod == null) { initGameViewMethod(); } UnityEditor.EditorWindow gameviewWindow = (UnityEditor.EditorWindow)getMainGameViewMethod.Invoke(null, null); if (gameviewWindow != null) { gameviewWindow.Repaint(); } #endif }
private static bool IsGameViewVSyncEnabled() { bool result = true; #if UNITY_EDITOR && UNITY_2019_1_OR_NEWER System.Reflection.Assembly assembly = typeof(UnityEditor.EditorWindow).Assembly; System.Type type = assembly.GetType("UnityEditor.GameView"); UnityEditor.EditorWindow window = UnityEditor.EditorWindow.GetWindow(type); System.Reflection.PropertyInfo prop = type.GetProperty("vSyncEnabled"); if (prop != null) { result = (bool)prop.GetValue(window); } #endif return(result); }
static public void ShowReadme(string name, string text, bool richText, bool markdownish, Component component, bool force) { if (!ShouldShowReadme(force)) { return; } System.Type t = GetWindowType(); if (t != null) { UnityEditor.EditorWindow w = t.GetMethod("GetInstance").Invoke(null, null) as UnityEditor.EditorWindow; if (w != null) { t.GetMethod("SetContent").Invoke(w, new object[] { name, text, richText, markdownish, component }); w.ShowUtility(); } } }
public static void CenterOnMainWin(this UnityEditor.EditorWindow aWin) { try { var main = GetEditorMainWindowPos(); var pos = aWin.position; float w = (main.width - pos.width) * 0.5f; float h = (main.height - pos.height) * 0.5f; pos.x = main.x + w; pos.y = main.y + h; aWin.position = pos; } catch (NotSupportedException e) { Debug.LogWarning( "The editor window wasn't centered: " + e ); } }
private static string GetSelectedStackTrace() { Assembly editorWindowAssembly = typeof(UnityEditor.EditorWindow).Assembly; if (editorWindowAssembly == null) { return(null); } System.Type consoleWindowType = editorWindowAssembly.GetType("UnityEditor.ConsoleWindow"); if (consoleWindowType == null) { return(null); } FieldInfo consoleWindowFieldInfo = consoleWindowType.GetField("ms_ConsoleWindow", BindingFlags.Static | BindingFlags.NonPublic); if (consoleWindowFieldInfo == null) { return(null); } UnityEditor.EditorWindow consoleWindow = consoleWindowFieldInfo.GetValue(null) as UnityEditor.EditorWindow; if (consoleWindow == null) { return(null); } if (consoleWindow != UnityEditor.EditorWindow.focusedWindow) { return(null); } FieldInfo activeTextFieldInfo = consoleWindowType.GetField("m_ActiveText", BindingFlags.Instance | BindingFlags.NonPublic); if (activeTextFieldInfo == null) { return(null); } return((string)activeTextFieldInfo.GetValue(consoleWindow)); }
public void OnEnable() { //Debug.Log("Spout.OnEnable"); if (_instance != null && _instance != this) { //Debug.Log("Spout.OnEnable.Destroy"); #if UNITY_EDITOR DestroyImmediate(this.gameObject); #else Destroy(this.gameObject); #endif return; } newSenders = new List <TextureInfo>(); stoppedSenders = new List <TextureInfo>(); activeSenders = new List <TextureInfo>(); activeLocalSenders = new List <TextureInfo>(); localSenderNames = new HashSet <string>(); #if UNITY_EDITOR assembly = typeof(UnityEditor.EditorWindow).Assembly; gameviewType = assembly.GetType("UnityEditor.GameView"); gameview = UnityEditor.EditorWindow.GetWindow(gameviewType); #endif #if UNITY_EDITOR if (_isEnabledInEditor || Application.isPlaying) { _Enable(); } #else _Enable(); #endif }
public zFullWindow(UnityEditor.EditorWindow window) { win = window; }
private void Initialize() { _gameWindow = GetMainGameView(); _windowParentBoundsAccessor = GetWindowParentBoundsAccessor(_gameWindow); _toolbarHeight = GetToolbarHeight(); _initialized = true; }
private void Initialize() { _gameWindow = GetMainGameView(); _initialized = true; }
public static void CenterInScreen(this UnityEditor.EditorWindow window, float width, float height) { Vector2Int resolution = ResolutionOption.GetLargestSupportedResolution().Dimensions; window.position = new Rect((resolution.x - width) * 0.5f, (resolution.y - height) * 0.5f, width, height); }
public static void EndCaptureRenderDoc(UnityEditor.EditorWindow window) => window.m_Parent.EndCaptureRenderDoc();
public void OnEnable(){ //Debug.Log("Spout.OnEnable"); if(_instance != null && _instance != this ) { //Debug.Log("Spout.OnEnable.Destroy"); #if UNITY_EDITOR DestroyImmediate(this.gameObject); #else Destroy(this.gameObject); #endif return; } newSenders = new List<TextureInfo>(); stoppedSenders = new List<TextureInfo>(); activeSenders = new List<TextureInfo>(); activeLocalSenders = new List<TextureInfo>(); localSenderNames = new HashSet<string>(); #if UNITY_EDITOR assembly = typeof(UnityEditor.EditorWindow).Assembly; gameviewType = assembly.GetType( "UnityEditor.GameView" ); gameview = UnityEditor.EditorWindow.GetWindow(gameviewType); #endif #if UNITY_EDITOR if(_isEnabledInEditor || Application.isPlaying){ _Enable(); } #else _Enable(); #endif }
/// <summary> /// 显示一个Tip信息 /// </summary> /// <param name="thisRef"></param> /// <param name="content"></param> public static void ShowTip(this UnityEditor.EditorWindow thisRef, string content) { thisRef.ShowNotification(new UnityEngine.GUIContent(content)); }
public static bool IsWindowOpened(UnityEditor.EditorWindow win) => _allOpenedWindows.Values.Where(s => s == win).Count() > 0;
public UnityEditorIMGUIControlsTreeViewController(UnityEditor.EditorWindow editorWindow, UnityEditor.IMGUI.Controls.TreeViewState treeViewState) { m_instance = Activator.CreateInstance(UnityTypes.UnityEditor_IMGUI_Controls_TreeViewController, new object[] { editorWindow, treeViewState }); }