Is it possible to execute a method of CustomEditor from another script?
For example, I have two scripts:
CustomEditor1 is attached to Object1 and CustomEditor2 is attached to Object2.
Then, when the [Add Scripts] button of CustomEditor1 is pressed on Inspector, I would like to also execute the process when the [Update Scripts] button of CustomEditor2 is pressed.
Is this possible?
CustomEditor1 .cs
public class CustomEditor1 : MonoBehaviour
{
}
[CustomEditor(typeof(CustomEditor1))]
public class CustomEditor1Editor : Editor
{
public override void OnInspectorGUI()
{
base.OnInspectorGUI();
if (GUILayout.Button("Add Scripts"))
{
AddScripts();
}
}
public void AddScripts()
{
Debug.Log("Add Scripts");
}
}
CustomEditor2.cs
public class CustomEditor2 : MonoBehaviour
{
}
[CustomEditor(typeof(CustomEditor2))]
public class CustomEditor2Editor : Editor
{
public override void OnInspectorGUI()
{
base.OnInspectorGUI();
if (GUILayout.Button("Update Scripts"))
{
UpdateScripts();
}
}
public void UpdateScripts()
{
Debug.Log("Update Scripts");
}
}