private void HandleSearch() { // Checks if any window of type MyWindow is open if (SearchWindow.HasOpenInstances <SearchWindow>()) { var _window = SearchWindow.GetWindow(typeof(SearchWindow)); _window.Close(); } SearchWindow window = (SearchWindow)SearchWindow.GetWindow(typeof(SearchWindow)); window.titleContent = new GUIContent("Search", (Texture2D)Resources.Load <Texture2D>(searchModalIcon)); window.Show(); AddFilesToSearch(window); }