Hi.
I made a javascript (“DetailMassPlace”) to autogenerate grass detail on a terrain. I need to make another script (“DetailMassPlaceEditor”) to create a button in the inspector to apply the grass. My editor-script looks like this:

@CustomEditor(DetailMassPlace)

public class DetailMassPlaceEditor extends Editor {
 
    override function OnInspectorGUI () {
        DrawDefaultInspector();

        if(GUILayout.Button("Apply")) {
           	updateLayer();
        }
   }
}

The updateLayer() function is a function inside “DetailMassPlace”.
How do i call that function from the other script “DetailMassPlaceEditor”?

You use target, which returns a direct reference to the object you are inspecting. My code is in C#, but there is not much to translate.

DetailMassPlace _target;
//get the reference when starting inspection
void OnEnable(){
    //target returns Object, so we cast it
    _target = (DetailMassPlace)target; 
}
    
//in your OnInspectorGUI, or whenever you want to call
//functions in the target
_target.updateLayer();