Hi,
[CustomEditor (typeof(TestClass))]
public class TestClassEditor : Editor
{
float a = 1;
float b = 2;
public void sum ()
{
Debug.Log (a + b);
}
public override void OnInspectorGUI ()
{
a = EditorGUILayout.FloatField (a);
b = EditorGUILayout.FloatField (b);
if (GUI.Button(new Rect(20, 300, 100, 30), new GUIContent("sum")))
sum ();
}
}
In editor i can select gameobject and click on “sum” button, but I want to do this (call sum function) from another editor script.
e.g I could access to the game object with this code in another editor script:
GameObject obj = GameObject.Find ("object name");
obj.GetComponent <TestClass> (); // not TestClassEditor
but I want to do something like this:
GameObject obj = GameObject.Find ("object name");
obj.GetComponent <TestClassEditor> ().sum ();
Any idea?
Thanks