I want to know if I can create a custom editor for an abstract class from which several other classes are derived. I want to do this because I want all of the derived classes to have a GUI button on them that can call a method that originates in the abstract base class.
public abstract class BaseClass : ScriptableObject
{
public virtual void SomeMethod()
{
// some code...
}
}
public class SomeClass : BaseClass
{
public override void SomeMethod()
{
base.SomeMethod;
// class-specific code
}
}
public class BaseClassEditor: Editor
{
public override void OnInspectorGUI()
{
base.OnInspectorGUI();
var myTarget = target as BaseClass;
if (GUILayout.Button("Do Something"))
{
myTarget.DoSomething();
}
}
}
I’m fairly certain this isn’t going to work because of var myTarget = target as BaseClass;in the editor script. Is there a way that I can get this functionality?