Access other script from Editor script

Hi, is it possible to access other script from Editor script (no the one It’s editing). As i understand i can’t use getcomponent or other “usual” methods.

Thank you very much.

I was right in my comment. You just need to cast is as MonoBehavior.

If your ScriptB is attached to the same GameObject, just do what I told in my comment. If it’s in a different gameObject, you can do GameObject.Find or the other usual ways.

ScriptB b;
	
void OnEnable(){
	script = ((MonoBehaviour)target).gameObject.GetComponent<ScriptB>();
	b.YourFunction();
}

I Would Like To Add That While **The Above Code IS Completely Correct.**Sometimes Unity Doesn’t Update Properly and Still Throws Null Exception Error…

You can Also Write the Above Code Like This (As of Unity 2018.1.2f1):

GameObject go = GameObject.Find("somegameobjectname");
ScriptB other = go.GetComponent<ScriptB>()
other.DoSomething();

{NOTE : Don’t Do GameObject.Find in Update Loop.It Can Slow Down Game…Just for the beginners out there}

In That Case Do A Couple OF things Which May Solve the issue :-

 1. Make Sure You Are In Play Mode.
 2. Clear The Cache.
 3. Restart Unity (If necessary PC)