Skip to content

Event handler for UIToolkit #3

@paulpach

Description

@paulpach

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions