Calling Method of Monobehaviour class from EditorWindow class

Hi,

Is there any way to call a method defined in Monobehaviour inherited class from EditorWindow inherited class?

I am developing one Editor Extension to Unity. I need to create menu item which will open an editor window. Now on these windows depending upon some button actions i need to do Export and Build APK for Android.
As Export and Build APK works for the classes which are intherited to Monobehaviour only, I am not able to call them from a class which are inherited to EditorWindow. I have created all buttons under EditorWindow class only.

Here is the way I am doing

//Editor window class

[MenuItem(“Tools/Test”)]

public static void showWindow ()
{
	EditorWindow.GetWindowWithRect (typeof(NewBehaviourScript), new Rect (0, 0, 300, 400), true, "Test Extension");

}

void ONGUI{

if (GUI.Button (new Rect (40, 120, 200, 40), “Export”)) {
ExportAPK(); //How to call this correctly???
}

	if (GUI.Button (new Rect (40, 220, 200, 40), "Build")) {								
		BuildAPK();  //How to call this correctly???
	}		

}

Now here is my monobehaviour class

public class BuildExport: MonoBehaviour
{

if (EditorUserBuildSettings.activeBuildTarget == BuildTarget.Android) {
EditorUserBuildSettings.SwitchActiveBuildTarget (BuildTarget.Android);
BuildPipeline.BuildPlayer (null, Path , BuildTarget.Android, BuildOptions.None);
}

public bool BuildAPK ()
{
if (EditorUserBuildSettings.activeBuildTarget == BuildTarget.Android) {
EditorUserBuildSettings.SwitchActiveBuildTarget (BuildTarget.Android);
BuildPipeline.BuildPlayer (null, Path, BuildTarget.Android, BuildOptions.AcceptExternalModificationsToPlayer);
}

Please help. I need to call BuildAPK() and ExportAPK() from EditorWindow class as mentioned above . I have written infront of those function “How to call this correctly”

Please provide a soultion as help is needed urgently.

Thanks & regards,
AKS.

You cannot unless you have a game object in the current scene when you open the editor window (in which case you’ll just use FindObjectOfType to get reference to the current monobehavior you’re looking for).

If you haven’t such object in the scene there’s still another option: make those methods as static (if they use parameters from the monobehavior you’ll need to pass those values as parameter to the functions).