(contained in a [ExecuteInEditMode] Monobehaviour class)
public void OnEnable()
{
var root = GetComponent<UIDocument>().rootVisualElement;
Button setPrefabButton = root.Q<Button>("set-prefab");
setPrefabButton.RegisterCallback<ClickEvent>(ev => { print("AAAA"); }); //Not working
setPrefabButton.clicked += () => { print("AAAA"); }; //Not working
}
I did some tests and it detects when the mouse hovers the button.
It does finds the button, if I try to debug.log the “setPrefabButton” it don’t returns me null.
OnEnable() is happening.
Yes there is. And it works pretty similar to what you are already doing. You’ve got to make a custom Editor. You must already be making a custom Editor to even show the button there, aren’t you?
There are multiple steps and I don’t know which ones you don’t know. You already know how to use a UITK button; all the other steps are explained there on the docs.