How to connect to an editor window, from a separate window/script?

I have a script that, upon a certain event, needs to connect to a separate editor window and call a function in that window’s script.

The first script is of the “extends Editor” type, and is providing a special Inspector view when it’s “@CustomEditor” object is selected. Pretty straightforward there.

However, I would like, when a button is pressed on that inspector, to call a function from a certain editor window. Unfortunately, I can’t seem to figure out how to connect to the window at all…any help? :frowning:

Thanks!

I haven’t done this myself (not with Editor classes, that is), but it sounds like you could use a static function in the editor window class. (‘static’ variables or functions exist once no matter how many copies of the class exist, and can be accessed without a reference to a class object)

class MyWindow /**/ {
  private var instance : MyWindow;

  function Initialize() { instance = this; }

  public static function VisibleFunction() {
    instance./*whatever*/;
  }
}

class MyInspector /**/ {
  ...
    MyWindow.VisibleFunction();
  ...
}

Ah, thanks Louis, I’ll try this… :slight_smile:

I think you can use EditorWindow.GetWindow.() as well, to get an instance reference.

Thanks also, superpig. Trying both these methods right now :slight_smile: