public static void Open() { Utility.CloseAllEditorWindows(typeof(NGSpotlightWindow)); POINT pos = new POINT(); NativeMethods.GetCursorPos(out pos); Rect r = Utility.GetEditorMainWindowPos(); NGSpotlightWindow window = EditorWindow.CreateInstance <NGSpotlightWindow>(); window.titleContent.text = NGSpotlightWindow.Title; window.position = new Rect(Mathf.Clamp(pos.x - NGSpotlightWindow.WindowWidth * .5F, r.x + 5F, r.xMax - NGSpotlightWindow.WindowWidth - 5F), r.y + r.height * .5F - NGSpotlightWindow.WindowHeight * .5F, NGSpotlightWindow.WindowWidth, NGSpotlightWindow.WindowHeight); window.minSize = new Vector2(NGSpotlightWindow.WindowWidth, NGSpotlightWindow.WindowHeight); window.maxSize = window.minSize; window.ShowPopup(); window.Focus(); }