How to call Editor script function from another Editor Window?

From within MyEditor, a popup EditorWindow (SettingsWindow) is opened.
From within SettingsWindow I need a button press to call a function in MyEditor.

The documents suggest using this:

 MyEditor ed = Resources.FindObjectsOfTypeAll<MyEditor>();

If that worked I could then access my function:


But FindObjectsOfTypeAll() gives the error: ‘The type or namespace name `MyEditor’ could not be found."

(In fact, the only place Resources.FindObjectsOfTypeAll(); actually works is within MyEditor, where of course it is redundant)

Is there a way to achieve this?



A hack until the best answer is submitted is using a static reference to the script (aka singleton).

It makes no sense to have a call cycle between those two classes. The settings window seems to be a utility window. So just provide everything the settings window need when you open / create it.

public class SettingsWindow : EditorWindow
    public MyEditor editor;
    // ...

// ...
// inside the "MyEditor" class:
void OpenSettings()
    SettingsWindow win = EditorWindow.CreateInstance<SettingsWindow>();
    win.editor = this;

About the type not found error, make sure you have placed both script files in a folder called “editor”. Also keep in mind that the file names have to match the classnames.