jonisavo / uicomponents

A small front-end framework for Unity's UIToolkit powered by code generation.
MIT License
186 stars 8 forks source link

Investigate generating UxmlFactory with source generation #51

Closed jonisavo closed 2 years ago

jonisavo commented 2 years ago

Classes derived from VisualElement must implement a UxmlFactory class to expose them to UXML and UI Builder. My idea is to automatically generate a simple implementation

public new class UxmlFactory : UxmlFactory<X> {}

with source generation if no UxmlFactory is defined. Users could then opt-out of this behaviour with an attribute like [DisableUxmlFactoryGeneration], which could be inherited.

jonisavo commented 2 years ago

The UxmlTraits generation implemented in #54 also generates UxmlFactory. At the moment, I don't think it's necessary to generate a UxmlFactory for every UIComponent. I consider this resolved.