- Home /
Is is possible to override the default Button editor?
I want to add a button ("Invoke now") to the Button inspector editor.
Generally it might look like this:
[CustomEditor(typeof(Button), true)]
public class ButtonClickInspector : UnityEditor.UI.ButtonEditor
{
public override void OnInspectorGUI()
{
Button b = (Button)target;
base.OnInspectorGUI();
if (GUILayout.Button("Invoke OnClick"))
{
b.onClick.Invoke();
}
}
}
However I'm not seeing anything different. In fact, I can comment out the 'base' call and it still looks like the default in the Inspector for Buttons. I'm assuming this means that the 'internal' ButtonEditor script is not being overridden.
Is the only way to override a Button editor to make a new button sub-class? I really don't want to do that, I want to be able to affect all Buttons.
FWIW The problem I'm trying to solve is being able to 'press buttons' in the Inspector, having hit 'Run' in the Editor, when it is inconvenient to find/click those buttons (let's say, building a Vive project with no Vive hardware available at the moment, and please don't go there!)