UIToolkit requires a lot of repetitive boilerplate for handling events. It would be awesome to have source generators for handling events. For example:
For example, It would be awesome to have something like this:
public partial class MyWindowController: MonoBehavior {
[UIHandler("OK", nameof(OnClicked))]
public Button okButton;
would generate something like this:
[RequireComponent(typeof(UIDocument))]
public partial class MyWindowController: MonoBehavior {
public Button okButton;
public void SubscribeUIHandler() {
TryGetComponent(out UIDocument document);
var root = document.root;
okButton = root.Q<Button>("OK");
okButton.clicked += OnClicked;
}
}
There are other types of events, so there could be more here.
UIToolkit requires a lot of repetitive boilerplate for handling events. It would be awesome to have source generators for handling events. For example:
For example, It would be awesome to have something like this:
would generate something like this:
There are other types of events, so there could be more here.